portAS.pl

1 March 2013

For years Chris Sharp, Erik Osaben and myself have been tweaking a script that somewhat automates the process of turning ActionScript 3 code into C/C++ code.

Idea being, there are many similarities between AS3 and C/C++ that can be largely addressed by search and replace rather than engineering. It walks directories and files, applying some regexp functions: file = a-z, A-Z, 0-9, _ import = &#60;white space&#62;import&#60;white space&#62;&#60;file&#62;; var = &#60;white space&#62; then one or more private or public or protected, with optional static, followed by var const = <white space> then one or more private or public or protected, with optional static, followed by const some mappings: int => int uint => unsigned int Boolean => bool Number => float String => std::string Dictionary => std::map<void, void> void => void Void => void Array => std::vector<void> Function => cppCallback MovieClip => MovieClip* * => void * .push( => .push_back( .pop( => .pop_back( .length => .size()” null => NULL undefined =>

NULL some special case handling of: functions plus getter and setters classes and interfaces and extends package if, for, do, while trace var comments plus automatic generation of constructors and destructors and emits a .h and .cpp file.

Time for an update?