浏览代码

[cpp] Fix cpp:Struct cast for Dynamic args

hughsando 6 年之前
父节点
当前提交
e8b8ddbbb4
共有 3 个文件被更改,包括 12 次插入3 次删除
  1. 1 1
      src/generators/gencpp.ml
  2. 10 1
      std/cpp/StdString.hx
  3. 1 1
      std/cpp/vm/Thread.hx

+ 1 - 1
src/generators/gencpp.ml

@@ -4393,7 +4393,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
                        | TCppStar (t,const) ->
                           output ("(cpp::" ^ (if const then "Const" else "") ^"Pointer<" ^ (tcpp_to_string t)^" >) ")
                        | TCppInst(t) when has_meta_key t.cl_meta Meta.StructAccess ->
-                          output ("(cpp::Struct< " ^ (tcpp_to_string return_type) ^ " >) ");
+                          output ("(cpp::Struct< " ^ (tcpp_to_string arg) ^ " >) ");
                        | _ -> () );
                      output ("a" ^ (string_of_int i));
                   )  tcpp_args;

+ 10 - 1
std/cpp/StdString.hx

@@ -6,7 +6,8 @@ using cpp.NativeString;
 @:include("hx/StdString.h")
 @:stackOnly
 @:structAccess
-extern class StdString extends StdStringRef
+@:unrelfective
+extern class StdString
 {
    @:native("std::string::npos")
    public static var npos(default,null):Int;
@@ -18,5 +19,13 @@ extern class StdString extends StdStringRef
    //public function toString():String;
    //public function find(s:String):Int;
    //public function substr(pos:Int, len:Int):StdString;
+
+   public function c_str() : ConstPointer<Char>;
+   public function size() : Int;
+   public function find(s:String):Int;
+   public function substr(pos:Int, len:Int):StdString;
+   public function toString():String;
+   public function toStdString():StdString;
+
 }
 

+ 1 - 1
std/cpp/vm/Thread.hx

@@ -62,7 +62,7 @@ class Thread {
 		return untyped __global__.__hxcpp_thread_read_message(block);
 	}
 
-	@:keep function __compare(t) : Int {
+	@:keep function __compare(t:Thread) : Int {
 		return handle == t.handle ? 0 : 1;
 	}