How do you extern a C++ constructor/destructor?

Is there a way in which Haxe can extern a C/C++ constructor, as mentioned in the title, or is this implicit at compile-time when using the “new” keyword?

What exactly do you mean by extern here?

If this is normal haxe code compiled to c++ then it’s not a normal constructor exactly since in haxe you can put super anywhere and extension isn’t dealt in the same way,.

Okay… so what about in the situation below:

extern class Object
    public function new(?other:Object);

    public function getClassInfo():ClassInfo;
    public function isKindOf(info:ClassInfo):Bool;
    public function isSameAs(obj:Object):Bool;
    public function ref(obj:Object);
    public function unRef();
    public function unShare();

Oh so for an extern class.

I’ve seen things like this:

@:native("new wxObject")
public static function create () : cpp.Pointer<Object>;

public function deleteMe():Void;

But nothing directly with a haxe constructor, I don’t think that’s possible.

Maybe there’s a way to use @:functionCode like this:

Wait, so you can’t do anything like extern class Event extends Object? How is that dealt with?

I was talking about another thing sorry (the c++ code generated for a normal haxe class),
don’t worry about it that works :wink:

1 Like