It has to interoperate with the existing Objective-C class libraries. Even if Swift were stand-alone, had an all new class-library (or non-class library as it may be), there is quite a bit of complexity there. The reasons for this complexity are manifold: static type-systems of the sophistication that Swift is attempting are complex. Swift is way more complicated than Objective-C, even if the syntax may seem a lot more familiar if you're used to certain other languages. who was completely unfamiliar with Objective-C finished his first Cocoa application during the "Intro to Cocoa" session, and spoke about his amazement during the feedback. Swiftify is a comercial product which does many high and low-level transformations, producing code that appears to be (I haven't tested it much, tbh) nearly fully-functioning Swift code.Anecdotal evidence in favor of Objective-C (Swift wasn't around back then): at an early WWDC, a dev. Objc2Swift.js is a more fully-fledged, nifty converter that is semantically-aware and attempts to produce working code while respecting semantics, but it does not currently support emitting Swift 3, 4 and 5-compatible code. Main inspiration for writing this tool, I just thought augmenting it with a more modern Objective-C syntax and some semantical awareness would be nifty. Yahoo's Objc2Swift makes language transformations, but it has shortcomings as far as making large transpilations go: Its grammar implementation lacks modern Objective-C features (such as generic types), and it makes no semantic transformations, doing AST conversions only. Some other libraries and resources that are also concerned with automating the process of converting Objective-C to Swift to some degree include that I think are worth mentioning: (for more info on transformation passes, see aforementioned Architecture document page) Be extensible, as far as writing a new syntax/type-structure transformation pass is concerned.Whenever possible, make automatic, semantically correct transformations that will save the user some time from doing it manually later.Try to do as much as possible of the tedious laborious work of converting syntax and getting it ready for the user to make the last manual changes that will inevitably be necessary.Try to produce code that functions as close as possible to the original Objective-C source, with no surprises.Always produce valid Swift syntax as output (not necessarily semantically valid, though).That being said, there are a couple of main goals that I have in mind going forward with this: This is mostly a side project of mine to train my Swift and architecture chops. The program should output the contents of the files you pass into the standard output. f, -follow-imports Follows #import declarations in files in order to parse other relevant files. swift files on the same folder as the input files. Saves output of conversion to the filedisk as. Prints the conversion results to the terminal's standard output w, -target Specifies the output target for the conversion. To the standard output for diagnosing rewriting issues. Provides a target file path to diagnose during rewriting.Īfter each intention pass and after expression passes, the file is written Which may increase compatibility with previous Obj-C code. This forces Swift to create Objective-C-compatible subclassing structures May be more performant in some circumstances depending on complexity of originalĮmits attributes on definitions, and emits NSObject subclass and NSObjectProtocol conformance on protocols. force-ll Forces ANTLR parsing to use LL prediction context, instead of making an attempt at SLL first. If not specified, thread allocation is defined by the system Specifies the number of threads to use when performing parsing, as well as intention and expression passes. v, -verbose Prints progress information to the console while performing a transpiling job. Prints extra information before each declaration and member about the inner logical decisions of intention passes as they change the structure of declarations. Prints the type of each top-level resolved expression statement found in function bodies. c, -colorize Pass this parameter as true to enable terminal colorization during output. swift file with a matching output name on the target path. s, -skip-confirm Skips asking for confirmation prior to parsing. exclude-pattern takes priority over -include-pattern Provides a pattern for including matches from the initial Objective-C files search. Provides a file pattern for excluding matches from the initial Objective-C files search. h/.m files to convert, before presenting a prompt to confirm conversion of files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |