本文整理汇总了C++中luabind::object::interpreter方法的典型用法代码示例。如果您正苦于以下问题:C++ object::interpreter方法的具体用法?C++ object::interpreter怎么用?C++ object::interpreter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luabind::object
的用法示例。
在下文中一共展示了object::interpreter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
// TODO Move arguments from constructor to here?
void timer::start(luabind::object& f)
{
thread = player->create_lua_thread();
#ifndef NDEBUG
int old_top = lua_gettop(thread);
#endif
//function.push(thread);
f.push(f.interpreter());
lua_xmove(f.interpreter(), thread, 1);
assert(old_top + 1 == lua_gettop(thread));
timer_thread = boost::thread(&timer::count_down, this);
}
示例2: typeName
static ComponentTypeId
ComponentFactory_registerComponentType(
ComponentFactory* self,
const std::string& name,
luabind::object cls
) {
lua_State* L = cls.interpreter();
auto type = luabind::type(cls);
if (type != LUA_TUSERDATA) {
std::string typeName(
lua_typename(L, type)
);
throw std::runtime_error("Argument 2 must be class object, but is: " + typeName);
}
ComponentTypeId typeId = self->registerComponentType(
name,
[cls] (const StorageContainer& storage) {
luabind::object classTable = cls;
luabind::object obj = classTable();
auto component = std::unique_ptr<Component>(
luabind::object_cast<Component*>(obj, luabind::adopt(luabind::result))
);
component->load(storage);
return component;
}
);
cls["TYPE_ID"] = typeId;
return typeId;
}
示例3: build
luabind::object menu::build(luabind::object setting)
{
using namespace luabind;
lua_State *L = setting.interpreter();
const char *title = NULL;
object m;
if (!setting || luabind::type(setting) != LUA_TTABLE) { return m; }
iterator i(setting), end;
if (setting["title"]) { title = object_cast<const char *>(setting["title"]); }
else if (setting["t"]) { title = object_cast<const char *>(setting["t"]); }
else if (setting["label"]) { title = object_cast<const char *>(setting["label"]); }
else if (type(*i) == LUA_TSTRING)
{
title = object_cast<const char *>(*i);
i++;
}
m = globals(L)["lev"]["gui"]["menu"](title);
for (; i != end; i++)
{
if (type(*i) == LUA_TTABLE)
{
m["append"](m, *i);
}
}
return m;
}
示例4: set_voxel_physics_boxes
void set_voxel_physics_boxes(const luabind::object &node_o,
const luabind::object &buffer_o, sp_<VoxelRegistry> voxel_reg)
{
lua_State *L = node_o.interpreter();
GET_TOLUA_STUFF(node, 1, Node);
TRY_GET_TOLUA_STUFF(buf, 2, const VectorBuffer);
log_d(MODULE, "set_voxel_physics_boxes(): node=%p", node);
log_d(MODULE, "set_voxel_physics_boxes(): buf=%p", buf);
ss_ data;
if(buf == nullptr)
data = lua_tocppstring(L, 2);
else
data.assign((const char*)&buf->GetBuffer()[0], buf->GetBuffer().Size());
lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app");
app::App *buildat_app = (app::App*)lua_touserdata(L, -1);
lua_pop(L, 1);
up_<SetPhysicsBoxesTask> task(new SetPhysicsBoxesTask(
node, data, voxel_reg
));
auto *thread_pool = buildat_app->get_thread_pool();
thread_pool->add_task(std::move(task));
}
示例5: clear_voxel_geometry
void clear_voxel_geometry(const luabind::object &node_o)
{
lua_State *L = node_o.interpreter();
GET_TOLUA_STUFF(node, 1, Node);
log_d(MODULE, "clear_voxel_geometry(): node=%p", node);
CustomGeometry *cg = node->GetComponent<CustomGeometry>();
if(cg)
node->RemoveComponent(cg);
}
示例6: clear_voxel_physics_boxes
void clear_voxel_physics_boxes(const luabind::object &node_o)
{
lua_State *L = node_o.interpreter();
GET_TOLUA_STUFF(node, 1, Node);
log_d(MODULE, "clear_voxel_physics_boxes(): node=%p", node);
RigidBody *body = node->GetComponent<RigidBody>();
if(body)
node->RemoveComponent(body);
PODVector<CollisionShape*> previous_shapes;
node->GetComponents<CollisionShape>(previous_shapes);
for(size_t i = 0; i < previous_shapes.Size(); i++)
node->RemoveComponent(previous_shapes[i]);
}
示例7:
bool NPL::NPLHelper::StringToLuaObject(const char* input, int nLen, luabind::object& output, lua_State* pState)
{
NPLLex lex;
LexState* ls = lex.SetInput(input, nLen);
ls->nestlevel = 0;
try
{
NPLParser::next(ls); /* read first token */
if (ls->t.token == '{')
{
if (pState == 0)
pState = output.interpreter();
luabind::object tabGlobal = luabind::globals(pState);
luabind::object_index_proxy tabProxy = tabGlobal["__tmp"];
if (DeserializePureDataBlock(ls, tabProxy))
{
NPLParser::testnext(ls, ';');
if (ls->t.token == NPLLex::TK_EOS)
{
output = tabProxy;
// this is not necessary, the next call will overwrite this.
// tabGlobal["__tmp"] = luabind::detail::nil_type();
return true;
}
}
}
}
catch (const char* err)
{
OUTPUT_LOG("error: %s in NPLHelper::StringToLuaObject()\n", err);
return false;
}
catch (...)
{
OUTPUT_LOG("error: unknown error in NPLHelper::StringToLuaObject()\n");
return false;
}
return false;
}
示例8: set_8bit_voxel_geometry
void set_8bit_voxel_geometry(const luabind::object &node_o,
int w, int h, int d, const luabind::object &buffer_o,
sp_<VoxelRegistry> voxel_reg, sp_<AtlasRegistry> atlas_reg)
{
lua_State *L = node_o.interpreter();
GET_TOLUA_STUFF(node, 1, Node);
TRY_GET_TOLUA_STUFF(buf, 5, const VectorBuffer);
log_d(MODULE, "set_8bit_voxel_geometry(): node=%p", node);
log_d(MODULE, "set_8bit_voxel_geometry(): buf=%p", buf);
ss_ data;
if(buf == nullptr)
data = lua_tocppstring(L, 5);
else
data.assign((const char*)&buf->GetBuffer()[0], buf->GetBuffer().Size());
if((int)data.size() != w * h * d){
throw Exception(ss_()+"set_8bit_voxel_geometry(): Data size does not match"
" with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")");
}
lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app");
app::App *buildat_app = (app::App*)lua_touserdata(L, -1);
lua_pop(L, 1);
Context *context = buildat_app->get_scene()->GetContext();
CustomGeometry *cg = node->GetOrCreateComponent<CustomGeometry>(LOCAL);
interface::mesh::set_8bit_voxel_geometry(cg, context, w, h, d, data,
voxel_reg.get(), atlas_reg.get());
cg->SetOccluder(true);
cg->SetCastShadows(true);
}
示例9:
SynchronizedRunBuffer::SynchronizedRunBuffer(luabind::object const& delegate) :
_init(false) {
_state = delegate.interpreter();
}