Skip to content

Commit

Permalink
[js] support @:selfCall for extern methods (see HaxeFoundation#3441)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadako committed Nov 21, 2014
1 parent 981f34e commit bae7da5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module Meta = struct
| Rtti
| Runtime
| RuntimeValue
| SelfCall
| Setter
| SkipCtor
| SkipReflection
Expand Down
1 change: 1 addition & 0 deletions common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ module MetaInfo = struct
| Rtti -> ":rtti",("Adds runtime type informations",[UsedOn TClass])
| Runtime -> ":runtime",("?",[])
| RuntimeValue -> ":runtimeValue",("Marks an abstract as being a runtime value",[UsedOn TAbstract])
| SelfCall -> ":selfCall",("Translates method calls into calling object directly",[UsedOn TClassField; Platform Js])
| Setter -> ":setter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
| SkipCtor -> ":skipCtor",("Used internally to generate a constructor as if it were a native type (no __hx_ctor)",[Platforms [Java;Cs]; Internal])
| SkipReflection -> ":skipReflection",("Used internally to annotate a field that shouldn't have its reflection data generated",[Platforms [Java;Cs]; UsedOn TClassField; Internal])
Expand Down
5 changes: 5 additions & 0 deletions genjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ let rec gen_call ctx e el in_value =
gen_value ctx e;
spr ctx ")";
end
| TField (eo, (FInstance(_,_,cf) | FStatic(_,cf) | FAnon(cf))), _ when Meta.has Meta.SelfCall cf.cf_meta ->
gen_value ctx eo;
spr ctx "(";
concat ctx "," (gen_value ctx) el;
spr ctx ")"
| _ ->
gen_value ctx e;
spr ctx "(";
Expand Down

0 comments on commit bae7da5

Please sign in to comment.