浏览代码

[cpp] Autocast cpp.Pointer. Add as_var to cpp.ConstPointer

hughsando 8 年之前
父节点
当前提交
82786c8f93
共有 2 个文件被更改,包括 3 次插入8 次删除
  1. 2 1
      src/generators/gencpp.ml
  2. 1 7
      std/cpp/ConstPointer.hx

+ 2 - 1
src/generators/gencpp.ml

@@ -2972,7 +2972,8 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
                baseCpp.cppexpr, baseCpp.cpptype (* nothing to do *)
             else (match return_type with
                | TCppObjC(k) -> CppCastObjC(baseCpp,k), return_type
-               | TCppInst(k) -> CppCast(baseCpp,return_type), return_type
+               | TCppPointer(_,_)
+               | TCppInst(_) -> CppCast(baseCpp,return_type), return_type
                | TCppString -> CppCastScalar(baseCpp,"::String"), return_type
                | TCppCode(t) when baseStr <> (tcpp_to_string t)  ->
                      CppCast(baseCpp, t),  t

+ 1 - 7
std/cpp/ConstPointer.hx

@@ -21,7 +21,7 @@
  */
  package cpp;
 
-@:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer")
+@:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer") @:analyzer(as_var)
 extern class ConstPointer<T>
 {
    // ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers
@@ -56,12 +56,6 @@ extern class ConstPointer<T>
 
    public function reinterpret<Other>():Pointer<Other>;
 
-   inline public function typeCast<Other>():Pointer<Other>
-   {
-      var tmp:haxe.extern.AsVar<Pointer<Other>> = reinterpret();
-      return tmp;
-   }
-
    public function rawCast<Other>():RawPointer<Other>;
 
    public function at(inIndex:Int):Reference<T>;