Browse Source

fix with readonly/writeonly properties accesses

Nicolas Cannasse 15 years ago
parent
commit
2804368e07
2 changed files with 9 additions and 1 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 8 1
      genas3.ml

+ 1 - 0
doc/CHANGES.txt

@@ -5,6 +5,7 @@
 	flash9 : classes implementing ArrayAccess<T> are now dynamic (including TypedDictionary)
 	flash9 : classes implementing ArrayAccess<T> are now dynamic (including TypedDictionary)
 	all : allow "using" on typedefs
 	all : allow "using" on typedefs
 	as3 : minor fixes in genas3 and --gen-hx-classes
 	as3 : minor fixes in genas3 and --gen-hx-classes
+	as3 : fix with readonly/writeonly properties accesses
 
 
 2010-01-09: 2.05
 2010-01-09: 2.05
 	js : added js.Scroll
 	js : added js.Scroll

+ 8 - 1
genas3.ml

@@ -877,7 +877,11 @@ let generate_field ctx static f =
 			| CallAccess m ->
 			| CallAccess m ->
 				print ctx "%s function get %s() : %s { return %s(); }" rights id t m;
 				print ctx "%s function get %s() : %s { return %s(); }" rights id t m;
 				newline ctx
 				newline ctx
-			| _ -> ());
+			| NoAccess | NeverAccess ->
+				print ctx "%s function get %s() : %s { return $%s; }" (if f.cf_set = NoAccess then "protected" else "private") id t id;
+				newline ctx
+			| _ ->
+				());
 			(match f.cf_set with
 			(match f.cf_set with
 			| NormalAccess ->
 			| NormalAccess ->
 				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" rights id t id;
 				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" rights id t id;
@@ -885,6 +889,9 @@ let generate_field ctx static f =
 			| CallAccess m ->
 			| CallAccess m ->
 				print ctx "%s function set %s( __v : %s ) : void { %s(__v); }" rights id t m;
 				print ctx "%s function set %s( __v : %s ) : void { %s(__v); }" rights id t m;
 				newline ctx
 				newline ctx
+			| NoAccess | NeverAccess ->
+				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" (if f.cf_set = NoAccess then "protected" else "private") id t id;
+				newline ctx
 			| _ -> ());
 			| _ -> ());
 			print ctx "protected var $%s : %s" (s_ident f.cf_name) (type_str ctx f.cf_type p);
 			print ctx "protected var $%s : %s" (s_ident f.cf_name) (type_str ctx f.cf_type p);
 		end else begin
 		end else begin