Converting Actionscript syntax to Objective C

萝らか妹 提交于 2020-01-14 07:52:06

问题


I have a game I wrote in Actionscript 3 I'm looking to port to iOS. The game has about 9k LOC spread across 150 classes, most of the classes are for data models, state handling and level generation all of which should be easy to port.

However, the thought of rejiggering the syntax by hand across all these files is none too appealing. Are there tools that can help me speed up this process?

I'm not looking for a magical tool here, nor am I looking for a cross compiler, I just want some help converting my source files.


回答1:


I don't know of a tool, but this is the way I'd try and attack your problem if there really is a lot of (simple) code to convert. I'm sure my suggestion is not that useful on parts of the code that are very flash-specific (all the DisplayObject stuff?) and also not that useful on lots of your logic. But it would be fun to build! :-)

Partial automatic conversion should be possible, especially if the objects are just 'data containers', watch out for bringing too much as3-idiom over to objective-c though, it might not always be a good fit.

Unless you want to create your own (semi) parser for as3 you'd need some sort of a parser, apparently FlexPMD has one (never used it), and there probably are others.

After getting your hands on a parser you have to find some way of suggesting to the system what parts could be converted automatically. You could try and add rules to the parser/generator script for the general case. For more specific cases I'd use custom metadata on the actual class/property/method, assuming a real as3 parser would correctly parse those.

Now part of your work will shift from hand-converting files to hand-annotating files, but that might be ok for you.

Have the parser parse your classes and define actions based on your metadata that will determine what kind of objective-c class to generate. If you get this working it could at least get you all your classes, their simple properties and method signatures (getting the body of the methods converted might be a bit too much to ask but you could include it as a comment so you'd have a nice reference while hand-translating).

PS: if you make this into a one way process be very sure you don't need to re-generate it later - it would be bad if you find out that you have been modifying the generated code and somehow need to re-generate all those classes -- that would mean you'll have to redo all your hard work!




回答2:


I've started putting a tool together to take the edge off the menial aspects of this process.

I'm trying to figure out if there's enough interest to make it clean and stable enough to release for others to use. I may just do it anyway.

http://meanwhileatthelab.blogspot.com.au/2012/08/automating-process-of-converting-as3-to.html

It's so far saving me a lot of time while porting one of my fairly large games from AS3 to objc.




回答3:


Check out the Sparrow Framework. It's purported to be designed with Actionscript developers in mind, recreating classes that sort of emulate display list and things like that. You'll have to dive into some "rejiggering" for sure no matter what you do if you don't want to use the CS5 packager.

http://www.sparrow-framework.org/




回答4:


even if some solution exists, note that architectural logic is DIFFERENT, and many more other details. Anyway even if posible, You will have a strange hybrid. I am coming back from WWDC2012, and the message is (as always..) performance anf great user experience.

So You should rewrite using a different programming model.



来源:https://stackoverflow.com/questions/3870882/converting-actionscript-syntax-to-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!