本文整理汇总了C++中SquirrelObject::AttachToStackObject方法的典型用法代码示例。如果您正苦于以下问题:C++ SquirrelObject::AttachToStackObject方法的具体用法?C++ SquirrelObject::AttachToStackObject怎么用?C++ SquirrelObject::AttachToStackObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SquirrelObject
的用法示例。
在下文中一共展示了SquirrelObject::AttachToStackObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Next
BOOL SquirrelObject::Next(SquirrelObject &key,SquirrelObject &val)
{
if(SQ_SUCCEEDED(sq_next(m_Vm.GetVMPtr(),-2))) {
key.AttachToStackObject(-2);
val.AttachToStackObject(-1);
sq_pop(m_Vm.GetVMPtr(),2);
return TRUE;
}
return FALSE;
}
示例2: RegisterPlugin
////////////////////////////////////////////////////////////////////////////////
// register a script plugin (script-bound function)
////////////////////////////////////////////////////////////////////////////////
SQInteger RegisterPlugin(HSQUIRRELVM v)
{
// get squirrel object to register from stack
SquirrelObject o;
o.AttachToStackObject(2);
// first verify that there is a member function to retrieve the plugin info
if (!o.Exists("GetPluginInfo"))
return sq_throwerror(v, "Not a script plugin!");
// ask for its registration name
SqPlus::SquirrelFunction<PluginInfo&> f(o, "GetPluginInfo");
PluginInfo& info = f();
wxString s = info.name;
// look if a script plugin with the same name already exists
ScriptPlugins::iterator it = s_ScriptPlugins.find(s);
if (it != s_ScriptPlugins.end())
{
// already exists; release the old one
s_ScriptPlugins.erase(it);
Manager::Get()->GetLogManager()->Log(_("Script plugin unregistered: ") + s);
}
// finally, register this script plugin
it = s_ScriptPlugins.insert(s_ScriptPlugins.end(), std::make_pair(s, o));
Manager::Get()->GetLogManager()->Log(_("Script plugin registered: ") + s);
Manager::Get()->GetScriptingManager()->RegisterScriptPlugin(s, CreateMenu(s));
// this function returns nothing on the squirrel stack
return 0;
}
示例3: GetValue
SquirrelObject SquirrelObject::GetValue(const SQChar *key)/*const*/
{
SquirrelObject ret;
if(GetSlot(key)) {
ret.AttachToStackObject(-1);
sq_pop(m_Vm.GetVMPtr(),1);
}
sq_pop(m_Vm.GetVMPtr(),1);
return ret;
}
示例4: GetDelegate
SquirrelObject SquirrelObject::GetDelegate()
{
SquirrelObject ret;
if(_o._type == OT_TABLE || _o._type == OT_USERDATA)
{
sq_pushobject(m_Vm.GetVMPtr(),_o);
sq_getdelegate(m_Vm.GetVMPtr(),-1);
ret.AttachToStackObject(-1);
sq_pop(m_Vm.GetVMPtr(),2);
}
return ret;
}
示例5: Clone
SquirrelObject SquirrelObject::Clone()
{
SquirrelObject ret;
if(GetType() == OT_TABLE || GetType() == OT_ARRAY)
{
sq_pushobject(m_Vm.GetVMPtr(),_o);
sq_clone(m_Vm.GetVMPtr(),-1);
ret.AttachToStackObject(-1);
sq_pop(m_Vm.GetVMPtr(),2);
}
return ret;
}
示例6: GetAttributes
SquirrelObject SquirrelObject::GetAttributes(const SQChar *key)
{
SquirrelObject ret;
int top = sq_gettop(m_Vm.GetVMPtr());
sq_pushobject(m_Vm.GetVMPtr(),_o);
if(key)
sq_pushstring(m_Vm.GetVMPtr(),key,-1);
else
sq_pushnull(m_Vm.GetVMPtr());
if(SQ_SUCCEEDED(sq_getattributes(m_Vm.GetVMPtr(),-2))) {
ret.AttachToStackObject(-1);
}
sq_settop(m_Vm.GetVMPtr(),top);
return ret;
}
示例7: CreateClass
BOOL CreateClass(HSQUIRRELVM v,SquirrelObject & newClass,SQUserPointer classType,const SQChar * name,const SQChar * baseName) {
int n = 0;
int oldtop = sq_gettop(v);
sq_pushroottable(v);
sq_pushstring(v,name,-1);
if (baseName) {
sq_pushstring(v,baseName,-1);
if (SQ_FAILED(sq_get(v,-3))) { // Make sure the base exists if specified by baseName.
sq_settop(v,oldtop);
return FALSE;
} // if
} // if
if (SQ_FAILED(sq_newclass(v,baseName ? 1 : 0))) { // Will inherit from base class on stack from sq_get() above.
sq_settop(v,oldtop);
return FALSE;
} // if
newClass.AttachToStackObject(-1);
sq_settypetag(v,-1,classType);
sq_createslot(v,-3);
sq_pop(v,1);
return TRUE;
} // CreateClass