本文整理汇总了C++中Assembly::getLuaState方法的典型用法代码示例。如果您正苦于以下问题:C++ Assembly::getLuaState方法的具体用法?C++ Assembly::getLuaState怎么用?C++ Assembly::getLuaState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assembly
的用法示例。
在下文中一共展示了Assembly::getLuaState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _as
static int _as(lua_State *L)
{
// as of null returns null
if (lua_isnil(L, 1))
{
lua_pushnil(L);
return 1;
}
// get the assembly lookup table
lua_rawgeti(L, LUA_GLOBALSINDEX, LSASSEMBLYLOOKUP);
// push the (interned) assembly name
lua_pushvalue(L, 2);
lua_gettable(L, -2);
// get the Assembly*
Assembly *assembly = (Assembly *)lua_topointer(L, -1);
lua_pop(L, 2);
lmAssert(assembly, "Object::_as - unable to get Assembly");
LSLuaState *lstate = assembly->getLuaState();
// the castType is the type we're casting to
Type *castType = assembly->getTypeByOrdinal((LSTYPEID)lua_tonumber(L, 3));
lmAssert(castType, "Object::_as - unable to resolve TypeID %u", (LSTYPEID)lua_tonumber(L, 3));
// checking number -> enum coercian
if (lua_isnumber(L, 1))
{
if (castType->isEnum())
{
lua_pushvalue(L, 1);
return 1;
}
}
bool valid = false;
if (castType == lstate->numberType)
{
if (lua_isnumber(L, 1))
{
valid = true;
}
}
else if (castType == lstate->stringType)
{
if (lua_isstring(L, 1))
{
valid = true;
}
}
else if (castType == lstate->booleanType)
{
if (lua_isboolean(L, 1))
{
valid = true;
}
}
else if (castType == lstate->functionType)
{
if (lua_iscfunction(L, 1))
{
valid = true;
}
else if (lua_isfunction(L, 1))
{
valid = true;
}
}
else
{
// If it's a primitive type but we expected an instance table, it is nil.
valid = true;
if (lua_isnumber(L, 1))
{
valid = false;
}
else if (lua_isstring(L, 1))
{
valid = false;
}
else if (lua_isboolean(L, 1))
{
valid = false;
}
else if (lua_iscfunction(L, 1))
{
valid = false;
}
else if (lua_isfunction(L, 1))
{
valid = false;
}
if (valid)
{
// If we are not a primitive type (as detected previously)
// we should be an instance table, if not something went horribly wrong
if (!lua_istable(L, 1))
//.........这里部分代码省略.........