Browse Source

[cpp] Add pointer reinterpret and work a bit on finalizer

Hugh 11 years ago
parent
commit
0d34c9138e
3 changed files with 7 additions and 3 deletions
  1. 2 1
      gencpp.ml
  2. 2 0
      std/cpp/Pointer.hx
  3. 3 2
      std/cpp/vm/Gc.hx

+ 2 - 1
gencpp.ml

@@ -629,7 +629,8 @@ and is_dynamic_array_param haxe_type =
    else (match follow haxe_type with
    else (match follow haxe_type with
    | TInst (klass,params) ->
    | TInst (klass,params) ->
          (match klass.cl_path with
          (match klass.cl_path with
-         | ([],"Array") | ([],"Class") | (["cpp"],"FastIterator") | (["cpp"],"Pointer") |(["cpp"],"ConstPointer") -> false
+         | ([],"Array") | ([],"Class") | (["cpp"],"FastIterator")
+         | (["cpp"],"Pointer") |(["cpp"],"ConstPointer")|(["cpp"],"Function") -> false
          | _ -> (match klass.cl_kind with KTypeParameter _ -> true | _ -> false)
          | _ -> (match klass.cl_kind with KTypeParameter _ -> true | _ -> false)
          )
          )
    | _ -> false
    | _ -> false

+ 2 - 0
std/cpp/Pointer.hx

@@ -11,6 +11,8 @@ extern class Pointer<T> extends ConstPointer<T> implements ArrayAccess<T>
 
 
 	public static function arrayElem<T>(array:Array<T>, inElem:Int):Pointer<T>;
 	public static function arrayElem<T>(array:Array<T>, inElem:Int):Pointer<T>;
 
 
+	public function reinterpret<Other>():Pointer<Other>;
+
 	override public function inc():Pointer<T>;
 	override public function inc():Pointer<T>;
 	override public function dec():Pointer<T>;
 	override public function dec():Pointer<T>;
 	override public function incBy(inT:Int):Pointer<T>;
 	override public function incBy(inT:Int):Pointer<T>;

+ 3 - 2
std/cpp/vm/Gc.hx

@@ -92,9 +92,10 @@ class Gc
       untyped __global__.__hxcpp_exit_gc_free_zone();
       untyped __global__.__hxcpp_exit_gc_free_zone();
    }
    }
 
 
-   static public function setFinalizer<T>(inObject:T, inFinalizer:cpp.Function<T->Void> ) : Void
+   @:unreflective
+   inline static public function setFinalizer<T>(inObject:T, inFinalizer:cpp.Function<T->Void> ) : Void
    {
    {
-      untyped __global__.__hxcpp_set_finalizer(inObject, inFinalizer.ptr);
+      untyped __global__.__hxcpp_set_finalizer(inObject, inFinalizer);
    }
    }
 }
 }