-
-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flash] native property support rework (#8241)
* add @:flash.property metadata * factor out the assignment generation function * merge this/super.field() call processing into the generic field call case * extract field call generation into a separate function * add a note * rewrite extern get_/set_ calls to a property access (when the property is there) * extract some functions * extract more fucntions * only consider non-physical properties when searching for properties for an accessor * implement native getter/setter generation * make swf loader generate proper get/set properties * support private fields in genhxold * patch getter/setter along with property type * regenerate flash externs with new extern properties * also rewrite static extern property accessors * also generate static native properties * remove @:flash.property, we don't really need it * realize inherited fake accessors that are required by interfaces * do not try to "realize" methods on interfaces, lol * don't process interfaces that are already implemented by the super class * also generate native getter/setter for properties with inherited get_/set_ * bring back the old overriding logic for normal @:getter/@:setter methods * re-introduce @:flash.property * only consider @:flash.property properties for generating native property(access) * really bring back the old overriding logic for normal @:getter/@:setter methods * error when implementing a native property without marking it with @:flash.property * make as3 tests pass should be good enough * add some tests
- Loading branch information
Showing
256 changed files
with
3,827 additions
and
1,314 deletions.
There are no files selected for viewing
This file contains 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 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 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,60 @@ | ||
(* | ||
The Haxe Compiler | ||
Copyright (C) 2005-2019 Haxe Foundation | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*) | ||
open Type | ||
|
||
let is_getter_name name = ExtString.String.starts_with name "get_" | ||
let is_setter_name name = ExtString.String.starts_with name "set_" | ||
let get_property_name accessor_name = String.sub accessor_name 4 (String.length accessor_name - 4) | ||
let is_flash_property cf = Meta.has Meta.FlashProperty cf.cf_meta | ||
|
||
let find_property_for_accessor ~isget cl tl accessor_name = | ||
let prop_name = get_property_name accessor_name in | ||
try | ||
match Type.class_field cl tl prop_name with | ||
| Some (prop_cl, prop_tl), _, prop_cf -> | ||
(match prop_cf.cf_kind with | ||
| Var { v_read = AccCall; v_write = AccCall | AccNever } when isget && is_flash_property prop_cf -> Some (prop_cl, prop_tl, prop_cf) | ||
| Var { v_read = AccCall | AccNever; v_write = AccCall } when not isget && is_flash_property prop_cf -> Some (prop_cl, prop_tl, prop_cf) | ||
| _ -> None) | ||
| _ -> None | ||
with Not_found -> | ||
None | ||
|
||
let is_extern_instance_accessor ~isget cl tl cf = | ||
if cl.cl_extern && (if isget then is_getter_name cf.cf_name else is_setter_name cf.cf_name) then | ||
find_property_for_accessor ~isget cl tl cf.cf_name | ||
else | ||
None | ||
|
||
let find_static_property_for_accessor ~isget cl accessor_name = | ||
let prop_name = get_property_name accessor_name in | ||
try | ||
let prop_cf = PMap.find prop_name cl.cl_statics in | ||
(match prop_cf.cf_kind with | ||
| Var { v_read = AccCall; v_write = AccCall | AccNever } when isget && is_flash_property prop_cf -> Some prop_cf | ||
| Var { v_read = AccCall | AccNever; v_write = AccCall } when not isget && is_flash_property prop_cf -> Some prop_cf | ||
| _ -> None) | ||
with Not_found -> | ||
None | ||
|
||
let is_extern_static_accessor ~isget cl cf = | ||
if cl.cl_extern && (if isget then is_getter_name cf.cf_name else is_setter_name cf.cf_name) then | ||
find_static_property_for_accessor ~isget cl cf.cf_name | ||
else | ||
None |
This file contains 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 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
Oops, something went wrong.