mixed C++/Script class

Started by
3 comments, last by WitchLord 10 years, 2 months ago

Hi,

Is there a way to easily add scripted methods to classes that are registered on the C++ class? Typically I would need to define a script class in C++, which has some method implementations written in angelscript (not C++). Something like:


int r = engine->RegisterObjectType("MyClass", 0, asOBJ_REF|asOBJ_NOCOUNT); assert( r >= 0 );
r = engine->RegisterObjectMethod("MyClass", "int method()", "return this.value;"); assert( r >= 0 );

I know it is not possible to do this directly, but is there a trick to do this already?

In fact,what would be nice is to be able to compile object methods just the same way you can already compile a function using CompileFunction().

Advertisement

SiCrane described in this forum thread how one can allow script classes to pseudo-inherit from a C++ class.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Ok thanks, will check it out!Looks like a pretty long thread :-)

I guess the wrapping solution is not a bad idea. However, it is not possible to define cast operators on the script side, is it? It seems it is reserved to application registered classes, right?

So far, yes.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement