Browse Source

[cpp] Fix interface casting for cppia. Do not inline native functions on cppia. Export IMap interface

Hugh 10 years ago
parent
commit
3b42bbf2ee
3 changed files with 12 additions and 6 deletions
  1. 9 3
      gencpp.ml
  2. 2 2
      std/haxe/io/Bytes.hx
  3. 1 1
      tests/unit/compile-cppia-host.hxml

+ 9 - 3
gencpp.ml

@@ -4603,6 +4603,7 @@ type cppia_op =
    | IaNoMain
    | IaNoMain
    | IaResources
    | IaResources
    | IaReso
    | IaReso
+   | IaNoCast
 
 
 	| IaBinOp of Ast.binop
 	| IaBinOp of Ast.binop
 ;;
 ;;
@@ -4685,7 +4686,7 @@ let cppia_op_info = function
    | IaNoMain -> ("NOMAIN", 76)
    | IaNoMain -> ("NOMAIN", 76)
    | IaResources -> ("RESOURCES", 77)
    | IaResources -> ("RESOURCES", 77)
    | IaReso -> ("RESO", 78)
    | IaReso -> ("RESO", 78)
-
+	| IaNoCast -> ("NOCAST", 79)
 
 
 	| IaBinOp OpAdd -> ("+", 101)
 	| IaBinOp OpAdd -> ("+", 101)
 	| IaBinOp OpMult -> ("*", 102)
 	| IaBinOp OpMult -> ("*", 102)
@@ -4954,8 +4955,13 @@ class script_writer common_ctx ctx filename asciiOut =
 
 
    if (not was_cast) then begin
    if (not was_cast) then begin
       if (forceCast) then begin
       if (forceCast) then begin
-         let toType = (type_string expr.etype) in
-         this#writeOpLine (if toType="int" then IaCastInt else if toType=="bool" then IaCastBool else IaCast);
+         let op =match (type_string expr.etype) with
+         | "int" -> IaCastInt
+         | "bool" -> IaCastBool
+         | _ when is_interface_type toType -> IaNoCast
+         | _ -> IaCast
+         in
+         this#writeOpLine op;
       end;
       end;
       this#gen_expression expr;
       this#gen_expression expr;
    end
    end

+ 2 - 2
std/haxe/io/Bytes.hx

@@ -213,7 +213,7 @@ class Bytes {
 		Returns the IEEE double precision value at given position (in low endian encoding).
 		Returns the IEEE double precision value at given position (in low endian encoding).
 		Result is unspecified if reading outside of the bounds
 		Result is unspecified if reading outside of the bounds
 	**/
 	**/
-	#if (neko_v21 || cpp) inline #end
+	#if (neko_v21 || (cpp && !cppia)) inline #end
 	public function getDouble( pos : Int ) : Float {
 	public function getDouble( pos : Int ) : Float {
 		#if neko_v21
 		#if neko_v21
 		return untyped $sgetd(b, pos, false);
 		return untyped $sgetd(b, pos, false);
@@ -232,7 +232,7 @@ class Bytes {
 		Returns the IEEE single precision value at given position (in low endian encoding).
 		Returns the IEEE single precision value at given position (in low endian encoding).
 		Result is unspecified if reading outside of the bounds
 		Result is unspecified if reading outside of the bounds
 	**/
 	**/
-	#if (neko_v21 || cpp) inline #end
+	#if (neko_v21 || (cpp && !cppia)) inline #end
 	public function getFloat( pos : Int ) : Float {
 	public function getFloat( pos : Int ) : Float {
 		#if neko_v21
 		#if neko_v21
 		return untyped $sgetf(b, pos, false);
 		return untyped $sgetf(b, pos, false);

+ 1 - 1
tests/unit/compile-cppia-host.hxml

@@ -1,6 +1,6 @@
 -main cpp.cppia.Host
 -main cpp.cppia.Host
 -D scriptable
 -D scriptable
--D dll_export=""
+-D dll_export=
 -debug
 -debug
 -dce no
 -dce no
 -cpp bin/cppia
 -cpp bin/cppia