• Advertisement
Sign in to follow this  

how can i register a stack to save interface in angelscript

This topic is 3345 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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:


engine->RegisterObjectMethod("stackOfBase", "void push(base@+)", asMETHOD(std::stack<asIScriptStruct*>, push), asCALL_THISCALL);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement