Skip to content

Commit

Permalink
add @:bridgeProperties, which creates native property bridges for all…
Browse files Browse the repository at this point in the history
… haxe properties in the annotated class
  • Loading branch information
Atry committed May 13, 2014
1 parent 7f93d8d commit 8511640
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions ast.ml 100755 → 100644
Expand Up @@ -38,6 +38,7 @@ module Meta = struct
| AutoBuild
| Bind
| Bitmap
| BridgeProperties
| Build
| BuildXml
| Class
Expand Down
1 change: 1 addition & 0 deletions common.ml
Expand Up @@ -340,6 +340,7 @@ module MetaInfo = struct
| AutoBuild -> ":autoBuild",("Extends @:build metadata to all extending and implementing classes",[HasParam "Build macro call";UsedOn TClass])
| Bind -> ":bind",("Override Swf class declaration",[Platform Flash;UsedOn TClass])
| Bitmap -> ":bitmap",("Embeds given bitmap data into the class (must extend flash.display.BitmapData)",[HasParam "Bitmap file path";UsedOn TClass;Platform Flash])
| BridgeProperties -> ":bridgeProperties",("Creates native property bridges for all Haxe properties in this class.",[UsedOn TClass;Platform Cs])
| Build -> ":build",("Builds a class or enum from a macro",[HasParam "Build macro call";UsedOnEither [TClass;TEnum]])
| BuildXml -> ":buildXml",("",[Platform Cpp])
| Class -> ":class",("Used internally to annotate an enum that will be generated as a class",[Platforms [Java;Cs]; UsedOn TEnum; Internal])
Expand Down
1 change: 1 addition & 0 deletions extra/CHANGES.txt
@@ -1,6 +1,7 @@
2014-??-??: 3.2.0

all : fixed nullability of abstracts over functions
cs : add @:bridgeProperties, which creates native property bridges for all haxe properties in the annotated class

2014-04-13: 3.1.3

Expand Down
Empty file modified extra/clean-whitespace 100755 → 100644
Empty file.
24 changes: 13 additions & 11 deletions gencs.ml
Expand Up @@ -30,6 +30,11 @@ open Printf
open Option
open ExtString

let netname_to_hx name =
let len = String.length name in
let chr = String.get name 0 in
String.make 1 (Char.uppercase chr) ^ (String.sub name 1 (len-1))

let rec is_cs_basic_type t =
match follow t with
| TInst( { cl_path = (["haxe"], "Int32") }, [] )
Expand Down Expand Up @@ -1932,7 +1937,7 @@ let configure gen =
| _ -> ()
)
with | Not_found -> ());
(* properties *
(* properties *)
let handle_prop static f =
match f.cf_kind with
| Method _ -> ()
Expand All @@ -1948,30 +1953,32 @@ let configure gen =
else
{ eexpr = TConst TThis; etype = TInst(cl,List.map snd cl.cl_types); epos = f.cf_pos }
in
print w "public %s%s %s" (if static then "static " else "") (t_s f.cf_type) f.cf_name;
print w "public %s%s %s" (if static then "static " else "") (t_s f.cf_type) (netname_to_hx f.cf_name);
begin_block w;
(match v.v_read with
| AccCall ->
write w "get";
begin_block w;
write w "return ";
expr_s w this;
print w "._get_%s();" f.cf_name;
print w ".get_%s();" f.cf_name;
end_block w
| _ -> ());
(match v.v_write with
| AccCall ->
write w "set";
begin_block w;
expr_s w this;
print w "._set_%s(value);" f.cf_name;
print w ".set_%s(value);" f.cf_name;
end_block w
| _ -> ());
end_block w;
end
in
List.iter (handle_prop true) cl.cl_ordered_statics;
List.iter (handle_prop false) cl.cl_ordered_fields*)
if Meta.has Meta.BridgeProperties cl.cl_meta then begin
List.iter (handle_prop true) cl.cl_ordered_statics;
List.iter (handle_prop false) cl.cl_ordered_fields;
end
in

let gen_class w cl =
Expand Down Expand Up @@ -2762,11 +2769,6 @@ type net_lib_ctx = {
nil : IlData.ilctx;
}

let netname_to_hx name =
let len = String.length name in
let chr = String.get name 0 in
String.make 1 (Char.uppercase chr) ^ (String.sub name 1 (len-1))

let hxpath_to_net ctx path =
try
Hashtbl.find ctx.ncom.net_path_map path
Expand Down
Empty file modified lexer.mll 100755 → 100644
Empty file.
Empty file modified main.ml 100755 → 100644
Empty file.
Empty file modified parser.ml 100755 → 100644
Empty file.

0 comments on commit 8511640

Please sign in to comment.