-
-
Notifications
You must be signed in to change notification settings - Fork 6
AS3ExternsGenerator: Generate externs under the flash package name too
#11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Fancy2209
wants to merge
15
commits into
openfl:master
Choose a base branch
from
Fancy2209:Flash-Externs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
067b5be
Remap openfl as flash on AS3 and TS Externs
Fancy2209 9adc624
Fix writing files in a while loop
Fancy2209 0fbbd2a
Update AS3ExternsGenerator.hx
Fancy2209 4f2c9a2
Fix outputFilePath remapping beeing too eager
Fancy2209 758da0f
Don't remap TS Externs
Fancy2209 b6f6c7d
Commit non automatic externs for flash package
Fancy2209 2eb0b86
AS3ExternsGenerator: Reimplement package remapping using regex
Fancy2209 13ea3e4
Merge branch 'openfl:master' into Flash-Externs
Fancy2209 dd97129
Remove remapPackages in favour of new renamePackages
Fancy2209 296795c
Fix missing newline at the end of TSExternsGenerator.hx
Fancy2209 1176e54
Fix build.hxml
Fancy2209 75e6eb3
Fix flash.utils package level functions
Fancy2209 ebf4888
Rename some Errors to the top level
Fancy2209 ed815fe
ExternsGenerators: Add includedSymbols
Fancy2209 9dcb0f1
Don't rename Errors to the top-level
Fancy2209 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package flash.display { | ||
|
|
||
|
|
||
| import flash.utils.ByteArray; | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| final public dynamic class ShaderData { | ||
|
|
||
|
|
||
| public function ShaderData (byteArray:ByteArray) {} | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package flash.net { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| * The URLVariables class allows you to transfer variables between an | ||
| * application and a server. Use URLVariables objects with methods of the | ||
| * URLLoader class, with the `data` property of the URLRequest | ||
| * class, and with flash.net package functions. | ||
| */ | ||
| public dynamic class URLVariables { | ||
|
|
||
|
|
||
| /** | ||
| * Creates a new URLVariables object. You pass URLVariables objects to the | ||
| * `data` property of URLRequest objects. | ||
| * | ||
| * If you call the URLVariables constructor with a string, the | ||
| * `decode()` method is automatically called to convert the string | ||
| * to properties of the URLVariables object. | ||
| * | ||
| * @param source A URL-encoded string containing name/value pairs. | ||
| */ | ||
| public function URLVariables (source:String = null) {} | ||
|
|
||
|
|
||
| /** | ||
| * Converts the variable string to properties of the specified URLVariables | ||
| * object. | ||
| * | ||
| * This method is used internally by the URLVariables events. Most users | ||
| * do not need to call this method directly. | ||
| * | ||
| * @param source A URL-encoded query string containing name/value pairs. | ||
| * @throws Error The source parameter must be a URL-encoded query string | ||
| * containing name/value pairs. | ||
| */ | ||
| public function decode (source:String):void {} | ||
|
|
||
|
|
||
| /** | ||
| * Returns a string containing all enumerable variables, in the MIME content | ||
| * encoding _application/x-www-form-urlencoded_. | ||
| * | ||
| * @return A URL-encoded string containing name/value pairs. | ||
| */ | ||
| public function toString ():String { return null; } | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.net { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function navigateToURL (request:URLRequest, window:String = null):void {} | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.net { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function sendToURL (request:URLRequest):void {} | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public dynamic class Dictionary { | ||
|
|
||
|
|
||
| public function Dictionary (weakKeys:Boolean = false) {} | ||
| // public function exists (key:*):Boolean { return false; } | ||
| // public function get (key:K):V { return null; } | ||
| // public function remove (key:*):Boolean { return false; } | ||
| // public function set (key:K, value:V):V { return null; } | ||
|
|
||
|
|
||
| // public inline function iterator ():Iterator<K> { | ||
|
|
||
| // return this.keys (); | ||
|
|
||
| // } | ||
|
|
||
|
|
||
| // public inline function each ():Iterator<V> { | ||
|
|
||
| // return this.iterator (); | ||
|
|
||
| // } | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function clearTimeout (id:uint):void {} | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function getDefinitionByName (name:String):* { return null; } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function getQualifiedClassName (value:*):String { return null; } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function getQualifiedSuperclassName (value:*):String { return null; } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function getTimer ():Number { return 0; } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package flash.utils { | ||
|
|
||
|
|
||
| /** | ||
| * @externs | ||
| */ | ||
| public function setTimeout (closure:Function, delay:Number, ...arguments):uint { return 0; } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing a replace over the entire file contents using the package name only feels dangerous. It could lead to things getting replaced that shouldn't be replaced. If someone wanted to use this option to remap "com", that would not work as well as "openfl", which is probably safer as long as things are case-sensitive. I've been trying to write the generators in a way that they might be useful to other projects too.
A safer version might be to replace
"package " + originalNameand":" + originalName. Or maybe regular expressions, to handle potential whitespace variations and things.However, even with this approach, doc comments may still include some replacements. There may not be a way to avoid that without calling the generator twice and remapping at an earlier stage of the process.
Not as important, but just something I that came to mind. I assume that this is inspired by Haxe's
--remapoption. I wonder if--remapsupports sub-packages, like--remap com.example:org.example. It would be good to either support that, or to throw an exception if a.character is contained in either the original or new name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using regular expressions may be the solution here, I feel like if an good approach for manipulating the end generated file could be cleaner
I am not sure about the subpackages.
Should I just try using the eregs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, go for it.
I realized that you might need one for imports too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally committed!