Browse Source

Cpp does not need to fixoverride on interfaces since it uses delegates. Can now use fast IntMap code without worrying about IMap fixing

Hugh 11 years ago
parent
commit
9649332c5f
3 changed files with 11 additions and 8 deletions
  1. 8 6
      codegen.ml
  2. 1 1
      gencommon.ml
  3. 2 1
      std/cpp/_std/haxe/ds/IntMap.hx

+ 8 - 6
codegen.ml

@@ -1139,7 +1139,7 @@ let stack_block ctx c m e =
 	exact same type for overriden/implemented function as the original one
 	exact same type for overriden/implemented function as the original one
 *)
 *)
 
 
-let rec find_field c f =
+let rec find_field com c f =
 	try
 	try
 		(match c.cl_super with
 		(match c.cl_super with
 		| None ->
 		| None ->
@@ -1147,14 +1147,16 @@ let rec find_field c f =
 		| Some ( {cl_path = (["cpp"],"FastIterator")}, _ ) ->
 		| Some ( {cl_path = (["cpp"],"FastIterator")}, _ ) ->
 			raise Not_found (* This is a strongly typed 'extern' and the usual rules don't apply *)
 			raise Not_found (* This is a strongly typed 'extern' and the usual rules don't apply *)
 		| Some (c,_) ->
 		| Some (c,_) ->
-			find_field c f)
+			find_field com c f)
 	with Not_found -> try
 	with Not_found -> try
+		if com.platform = Cpp then (* Cpp uses delegation for interfaces *)
+			raise Not_found;
 		let rec loop = function
 		let rec loop = function
 			| [] ->
 			| [] ->
 				raise Not_found
 				raise Not_found
 			| (c,_) :: l ->
 			| (c,_) :: l ->
 				try
 				try
-					find_field c f
+					find_field com c f
 				with
 				with
 					Not_found -> loop l
 					Not_found -> loop l
 		in
 		in
@@ -1165,7 +1167,7 @@ let rec find_field c f =
 		f
 		f
 
 
 let fix_override com c f fd =
 let fix_override com c f fd =
-	let f2 = (try Some (find_field c f) with Not_found -> None) in
+	let f2 = (try Some (find_field com c f) with Not_found -> None) in
 	match f2,fd with
 	match f2,fd with
 		| Some (f2), Some(fd) ->
 		| Some (f2), Some(fd) ->
 			let targs, tret = (match follow f2.cf_type with TFun (args,ret) -> args, ret | _ -> assert false) in
 			let targs, tret = (match follow f2.cf_type with TFun (args,ret) -> args, ret | _ -> assert false) in
@@ -1222,7 +1224,7 @@ let fix_overrides com t =
 		if c.cl_interface then
 		if c.cl_interface then
 			c.cl_ordered_fields <- List.filter (fun f ->
 			c.cl_ordered_fields <- List.filter (fun f ->
 				try
 				try
-					if find_field c f == f then raise Not_found;
+					if find_field com c f == f then raise Not_found;
 					c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 					c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 					false;
 					false;
 				with Not_found ->
 				with Not_found ->
@@ -1248,7 +1250,7 @@ let fix_abstract_inheritance com t =
 	match t with
 	match t with
 	| TClassDecl c when c.cl_interface ->
 	| TClassDecl c when c.cl_interface ->
 		c.cl_ordered_fields <- List.filter (fun f ->
 		c.cl_ordered_fields <- List.filter (fun f ->
-			let b = try (find_field c f) == f
+			let b = try (find_field com c f) == f
 			with Not_found -> false in
 			with Not_found -> false in
 			if not b then c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 			if not b then c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 			b;
 			b;

+ 1 - 1
gencommon.ml

@@ -10513,7 +10513,7 @@ struct
 				c.cl_ordered_fields <- List.filter (fun f ->
 				c.cl_ordered_fields <- List.filter (fun f ->
 					try
 					try
 						if Meta.has Meta.Overload f.cf_meta then raise Not_found;
 						if Meta.has Meta.Overload f.cf_meta then raise Not_found;
-						let f2 = Codegen.find_field c f in
+						let f2 = Codegen.find_field gen.gcon c f in
 						if f2 == f then raise Not_found;
 						if f2 == f then raise Not_found;
 						c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 						c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 						false;
 						false;

+ 2 - 1
std/cpp/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
  */
 package haxe.ds;
 package haxe.ds;
 
 
-@:headerClassCode_disable("
+@:headerClassCode("
   inline void set(int key, ::null value) { __int_hash_set(h,key,value); }
   inline void set(int key, ::null value) { __int_hash_set(h,key,value); }
   inline void set(int key, bool value) { __int_hash_set(h,key,value); }
   inline void set(int key, bool value) { __int_hash_set(h,key,value); }
   inline void set(int key, char value) { __int_hash_set_int(h,key,value); }
   inline void set(int key, char value) { __int_hash_set_int(h,key,value); }
@@ -34,6 +34,7 @@ package haxe.ds;
   inline void set(int key, float value) { __int_hash_set_float(h,key,value); }
   inline void set(int key, float value) { __int_hash_set_float(h,key,value); }
   inline void set(int key, double value) { __int_hash_set_float(h,key,value); }
   inline void set(int key, double value) { __int_hash_set_float(h,key,value); }
   inline void set(int key, ::String value) { __int_hash_set_string(h,key,value); }
   inline void set(int key, ::String value) { __int_hash_set_string(h,key,value); }
+  inline Void set(Dynamic key, ::Dynamic value) { __int_hash_set(h,key,value); return null(); }
 ")
 ")
 @:coreApi class IntMap<T> implements Map.IMap<Int,T> {
 @:coreApi class IntMap<T> implements Map.IMap<Int,T> {