You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2018/05/23 17:53:46 UTC

[GitHub] jgranick opened a new issue #246: Issues when porting Starling

jgranick opened a new issue #246: Issues when porting Starling
URL: https://github.com/apache/royale-asjs/issues/246
 
 
   We have been trying to build Starling using Apache Royale. Currently we have successfully released the Haxe->JS version of Starling using ActionScript @externs, but this is an attempt to move Starling out of JavaScript back to ActionScript, and to compile the full library.
   
   With workarounds, we're at the point of resolving circular references and some other runtime issues, but we wanted to share some of the issues that occurred along the way. My apologies about making a "super issue" with multiple items.
   
   
   ## openfl.errors.Error/flash.errors.Error
   
   ActionScript has top-level `Error`, `ArgumentError` and other error types. OpenFL supports them using `openfl.errors.Error`, `openfl.errors.ArgumentError` and so on. We can resolve this problem by making these types global or by adding imports to code that uses them, but the compiler has a `NullPointerException` when using `openfl.errors.Error`, due to the name collision with `Error` in the compiler.
   
   _Workaround: Removed `import openfl.errors.Error` and commented code that relied on `error.errorID`_
   
   
   ## Custom namespace
   
   I do not recall the error, but the `starling.core.starling_internal` namespace was resulting in errors in the compiler.
   
   _Workaround: Replaced `starling_internal` with `public` and commented the relevant `import` and `use` code_
   
   
   ## Importing within the same module
   
   Here is an example of what occurred, this resulted in errors in the compiler:
   
   ```
   package test {
       public class ClassA {
           ...
       }
   }
   import test.ClassA;
   class ClassB {
       ...
   }
   ```
   
   _Workaround: Removed the import reference (represented by `import test.ClassA` in the example)_
   
   
   ## ||=
   
   Use of the `||=` operator resulted in errors within the compiler. For example:
   
   ```as3
   target._tinted ||= _tinted;
   ```
   
   _Workaround: Converted code to avoid use of the operator:_
   
   ```as3
   if (!target._tinted) target._tinted = _tinted;
   ```
   
   
   ## XML
   
   I assume that XML (E4X) is not supported as it is not available in the browser, but a lot of ActionScript code relies on it. Are there recommended workarounds? Plans for a compiler-based workaround?
   
   
   ## Base classes defined in an SWC
   
   Using base extern classes as defined in an SWC was causing null exceptions in the compiler. Perhaps this is because no Google Closure JS files were generated for these types.
   
   _Workaround: Switched to pointing to @externs \*.as files instead of an \*.swc_
   
   
   ## super()
   
   At runtime, issues were experienced where a class instance did not have the members of it's super-class. It was revealed that the problem was that the class did not call `super()` in its constructor, thus the issue. Should this be implied in the Royale output, if the constructor does not call `super()`? 
   
   
   ## Reproduction
   
   The current state of the code (with workarounds) is available online.
   
   It currently requires a development version of OpenFL for NPM:
   
   ```
   git clone https://github.com/openfl/openfl
   cd openfl
   npm install
   npm run build -s
   npm link
   ```
   
   Then the remaining source files are all bundled in a test repository (where we can edit Starling's core files, etc)
   
   ```
   git clone https://github.com/jgranick/StarlingAS3Test
   cd StarlingAS3Test
   npm install
   npm link openfl
   npm start -s
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services