how can i register a stack to save interface in angelscript
GreateLord:
I want to define stack to save interface;
interface base
{
void enter();
}
class b : base
{
void enter()
{
}
}
//////////define a stack///////
stack.push( b );
how can i do it ?
in c++, we define std::stack<?> stacker;
what datatype "?" must be ?
Or, how can i simulate a stack in angelscript to save b?
If all types that will be put on the stack implements the base interface, then you should be able to register the "std::stack<asIScriptStruct*>" type to take a "base@" type. However, the std::stack template won't automatically handle the reference counting, so you might want to register the methods with autohandles, or otherwise write wrapper functions to increment/decrement the reference counter properly.
Example:
Example:
engine->RegisterObjectMethod("stackOfBase", "void push(base@+)", asMETHOD(std::stack<asIScriptStruct*>, push), asCALL_THISCALL);
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
Popular Topics
Advertisement