Advertisement

Register handle as reference

Started by July 09, 2014 08:57 AM
2 comments, last by cvet 9 years, 7 months ago

Hello.

In some cases need to register handle, but disable possibility to null it (e.g. like reference or value type).

Possible to add registering properties with this behaviour? Like this:

ScriptString* str = ScriptString::GetFromPool(); // Class can't be allocated on stack

Engine->RegisterGlobalProperty( "string& str", &str ); // Here i want register like handle, but protect from nulling it

Same for RegisterObjectProperty where need type class offset, not pointer.

You can register the global property like this:

ScriptString* str = ScriptString::GetFromPool();
Engine->RegisterGlobalProperty("string str", str);

For class members it is a bit more tricky. In this case it is currently only possible by using virtual properties (i.e. a couple of get/set functions).

I'll look into adding support for & when registering properties to indicate that the property needs to be de-referenced when accessed.

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

Advertisement

I've finally added support for registering class members as references, e.g.

engine->RegisterObjectProperty("type", "complex &cmplx", asOFFSET(type, cmplx));

This is available in revision 2142.

Regards,

Andreas

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

Thanks!

This topic is closed to new replies.

Advertisement