Jump to content

[SOLVED] Managed pointers to custom classes


photo

Recommended Posts

Greetings,

Say we have a custom class called Foo, which has managed Unigine pointers to another custom class called Bar.
So, here is Foo's definition for now :

class Foo
{
  	Unigine::Ptr<Bar> m_bar;
  
public:
  	Foo() = default;
  
  	void setBar(Unigine::Ptr<Bar> ptr){ m_bar = bar; }
}

Now, when I try to add this implementation to the Unigine interpreter, I use the following code :

Unigine::ExternClass<Foo>* fooClass = Unigine::MakeExternClass<Foo>();

fooClass->addConstructor();

fooClass->addFunction<Foo, void, Unigine::Ptr<Bar>>("setBar", &Foo::setBar);

Unigine::Interpreter::addExternClass("Foo", fooClass);

I get a compile error saying that 'release_ptr' is not a defined member of Foo. So, I defined 'static void release_ptr(Foo* p){ delete p; }' in the Foo class.

Now I get a "'type cast': cannot convert from 'void*' to 'Type' " in UnigineInterpreter.h.

Any ideas on how to solve this error?

Thanks in advance

Link to comment
  • silent changed the title to [SOLVED] Managed pointers to custom classes
×
×
  • Create New...