当前位置: 首页>>代码示例>>C++>>正文


C++ luabind::object类代码示例

本文整理汇总了C++中luabind::object的典型用法代码示例。如果您正苦于以下问题:C++ object类的具体用法?C++ object怎么用?C++ object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void parse_table	(luabind::object const &table, LPCSTR identifier, luabind::object &result)
{
	VERIFY2			(table.type() == LUA_TTABLE, "invalid loophole description passed");
	result			= table[identifier];
	VERIFY2			(result.type() != LUA_TNIL, make_string("cannot read table value %s", identifier));
	VERIFY2			(result.type() == LUA_TTABLE, make_string("cannot read table value %s", identifier));
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:7,代码来源:xrServer_Objects_Alife_Smartcovers.cpp

示例2:

void smart_cover::action::add_animation(LPCSTR type, luabind::object const &table)
{	
	VERIFY						( table.type() == LUA_TTABLE );
	luabind::object::iterator I	= table.begin();
	luabind::object::iterator E	= table.end();
	Animations* animations		= xr_new<Animations>( );
	for ( ; I != E; ++I) {
		luabind::object	string	= *I;
		if (string.type() != LUA_TSTRING) {
			VERIFY				( string.type() != LUA_TNIL );
			continue;
		}

		shared_str animation	= luabind::object_cast<LPCSTR>(string);
		VERIFY2					(
			std::find(
				animations->begin(),
				animations->end(),
				animation
			) == 
			animations->end(),
			make_string(
				"duplicated_animation found: %s",
				animation.c_str()
			)
		);
		animations->push_back	( animation );
	}

	m_animations.insert			( std::make_pair( type, animations ) );
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:31,代码来源:smart_cover_action.cpp

示例3: xr_string

xr_string to_string					(luabind::object const& o)
{
	using namespace luabind;
	if (o.type() == LUA_TSTRING) return object_cast<xr_string>(o);
	lua_State* L = o.lua_state();
	LUABIND_CHECK_STACK(L);

#ifdef BOOST_NO_STRINGSTREAM
	std::strstream s;
#else
	std::stringstream s;
#endif

	if (o.type() == LUA_TNUMBER)
	{
		s << object_cast<float>(o);
		return xr_string(s.str().c_str());
	}

	s << "<" << lua_typename(L, o.type()) << ">";
#ifdef BOOST_NO_STRINGSTREAM
	s << std::ends;
#endif
	return s.str().c_str();
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:25,代码来源:script_engine_help.cpp

示例4: p

xr_string member_to_string			(luabind::object const& e, LPCSTR function_signature)
{
#if !defined(LUABIND_NO_ERROR_CHECKING3)
    using namespace luabind;
	lua_State* L = e.lua_state();
	LUABIND_CHECK_STACK(L);

	if (e.type() == LUA_TFUNCTION)
	{
		e.pushvalue();
		detail::stack_pop p(L, 1);

		{
			if (lua_getupvalue(L, -1, 3) == 0) return to_string(e);
			detail::stack_pop p2(L, 1);
			if (lua_touserdata(L, -1) != reinterpret_cast<void*>(0x1337)) return to_string(e);
		}

#ifdef BOOST_NO_STRINGSTREAM
		std::strstream s;
#else
		std::stringstream s;
#endif
		{
			lua_getupvalue(L, -1, 2);
			detail::stack_pop p2(L, 1);
		}

		{
			lua_getupvalue(L, -1, 1);
			detail::stack_pop p2(L, 1);
			detail::method_rep* m = static_cast<detail::method_rep*>(lua_touserdata(L, -1));

			for (std::vector<detail::overload_rep>::const_iterator i = m->overloads().begin();
				i != m->overloads().end(); ++i)
			{
				xr_string str;
				i->get_signature(L, str);
				if (i != m->overloads().begin())
					s << "\n";
				s << function_signature << process_signature(str) << ";";
			}
		}
#ifdef BOOST_NO_STRINGSTREAM
		s << std::ends;
#endif
		return s.str().c_str();
	}

    return to_string(e);
#else
    return "";
#endif
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:54,代码来源:script_engine_help.cpp

示例5: 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);
}
开发者ID:alyssonbrito,项目名称:linux-opengl-player,代码行数:14,代码来源:timer.cpp

示例6: 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));
}
开发者ID:celeron55,项目名称:buildat,代码行数:29,代码来源:mesh.cpp

示例7: 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;
  }
开发者ID:akivajp,项目名称:levana,代码行数:29,代码来源:menu.cpp

示例8: getPosition

position LuaQuestScript::getPosition(const luabind::object &potentialPosition) {
    using namespace luabind;

    if (!potentialPosition.is_valid()) {
        throw std::logic_error("no position found");
    }

    try {
        return object_cast<position>(potentialPosition);
    } catch (cast_failed &e) {
    }

    auto positionType = type(potentialPosition);

    if (positionType == LUA_TTABLE) {
        try {
            int16_t x = object_cast<int16_t>(potentialPosition[1]);
            int16_t y = object_cast<int16_t>(potentialPosition[2]);
            int16_t z = object_cast<int16_t>(potentialPosition[3]);
            return position(x, y, z);
        } catch (cast_failed &e) {
        }
    }

    throw std::logic_error("no position found");
}
开发者ID:Illarion-eV,项目名称:Illarion-Server,代码行数:26,代码来源:LuaQuestScript.cpp

示例9: lua_newthread

void xd::lua::scheduler::start(luabind::object func)
{
	// create a new thread
	lua_State *thread = lua_newthread(m_vm.lua_state());
	// push the function in the new thread, because the function
	// the thread calls must be called in its local environment
	func.push(thread);
	// construct a callable object from it, the value is copied from stack
	luabind::object thread_func(luabind::from_stack(thread, -1));
	// remove the original value from the stack
	lua_pop(thread, 1);
	// set the current thread
	m_thread_stack->threads.push(thread);
	m_current_thread = thread;
	// start the thread
	luabind::object result = luabind::resume_function<luabind::object>(thread_func);
	// if the thread was yielded from lua side, and the return value is a callable function
	int type = luabind::type(result);
	if (type == LUA_TFUNCTION || type == LUA_TTABLE || type == LUA_TUSERDATA) {
		yield(xd::create<detail::callback_task_lua>(result));
	}
	// reset current thread
	m_thread_stack->threads.pop();
	if (m_thread_stack->threads.empty())
		m_current_thread = nullptr;
	else
		m_current_thread = m_thread_stack->threads.top();
}
开发者ID:Greyze,项目名称:xd,代码行数:28,代码来源:scheduler.cpp

示例10: luaL_error

void LuaProxy::Graphics::__setSimpleSpriteOverride(const std::string & name, const luabind::object & overrideImg, lua_State * L)
{
    HDC mainHdc, maskHdc;
    if (name.find("hardcoded-") == 0)
    {
        // If non of the above applies, then try with the hardcoded ones:
        HardcodedGraphicsItem::GetHDCByName(name, &mainHdc, &maskHdc);
    }
    if (mainHdc == nullptr && maskHdc == nullptr) {
        luaL_error(L, "Failed to get hardcoded image!");
        return;
    }
    
    SMBXMaskedImage* img = SMBXMaskedImage::get(mainHdc, maskHdc);
    if (!overrideImg.is_valid())
    {
        img->UnsetOverride();
        return;
    }

    boost::optional<SMBXMaskedImage*> maskImg = luabind::object_cast_nothrow<SMBXMaskedImage*>(overrideImg);
    if (maskImg != boost::none) {
        img->SetOverride(*maskImg);
        return;
    }

    boost::optional<LuaProxy::Graphics::LuaImageResource*> rgbaImg = luabind::object_cast_nothrow<LuaProxy::Graphics::LuaImageResource*>(overrideImg);
    if (rgbaImg != boost::none) {
        if (*rgbaImg != nullptr && (*rgbaImg)->img) {
            img->SetOverride((*rgbaImg)->img);
        }
        return;
    }
    luaL_error(L, "Invalid input for sprite override!");
}
开发者ID:zeriyoshi,项目名称:LunaDLL,代码行数:35,代码来源:LuaProxyGlobalFuncGraphics.cpp

示例11: parse_fvector

Fvector parse_fvector (luabind::object const &table, LPCSTR identifier)
{
	VERIFY2			(table.type() == LUA_TTABLE, "invalid loophole description passed");
	luabind::object	result = table[identifier];
	VERIFY2			(result.type() != LUA_TNIL, make_string("cannot read vector value %s", identifier));
	return			(luabind::object_cast<Fvector>(result));
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:7,代码来源:xrServer_Objects_Alife_Smartcovers.cpp

示例12: ComponentFactory_registerComponentType

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;
}
开发者ID:Acularius,项目名称:Thrive,代码行数:29,代码来源:component_factory.cpp

示例13: setGeometryIndices

void setGeometryIndices( Geometry * pGeom, const luabind::object & indexTable )
{
	if ( indexTable.is_valid() && indexTable.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_indexBuffer ) pGeom->m_indexBuffer.reset( new vector<unsigned short> );
		unsigned int uiNewIndices = 0;
		pGeom->m_indexBuffer->clear();
		for( luabind::object::array_iterator iter = indexTable.abegin();
			iter != indexTable.aend();
			iter++, uiNewIndices++ )
		{
			boost::optional<unsigned short> oindex = luabind::object_cast_nothrow<unsigned short>( *iter );
			if ( oindex )
				pGeom->m_indexBuffer->push_back( *oindex.get() );
		}
		pGeom->m_indexCount = uiNewIndices;
	}
}
开发者ID:ejabx,项目名称:katana,代码行数:18,代码来源:geometry_script.cpp

示例14: if

bool ReadScriptDescriptor::_CheckDataType(int32 type, luabind::object& obj_check) {
	int32 object_type = luabind::type(obj_check);

	if (obj_check.is_valid() == false)
		return false;

	// When this type is passed to the function, we don't care what type the object is as long
	// as it was seen to be something
	if (type == LUA_TNIL) {
		return true;
	}

	// Simple type comparison is all that is needed for all non-numeric types
	else if (type == object_type) {
		return true;
	}

	// Because Lua only has a "number" type, we have to do perform a special cast
	// to examine integer versus floating point types
	else if (object_type == LUA_TNUMBER) {
		if (type == INTEGER_TYPE) {
			try {
				luabind::object_cast<int32>(obj_check);
				return true;
			}
			catch (...) {
				return false;
			}
		}
		else if (type == UINTEGER_TYPE) {
			try {
				luabind::object_cast<uint32>(obj_check);
				return true;
			}
			catch (...) {
				return false;
			}
		}
		else if (type == FLOAT_TYPE) {
			try {
				luabind::object_cast<float>(obj_check);
				return true;
			}
			catch (...) {
				return false;
			}
		}
		else {
			return false;
		}
	}

	else {
		return false;
	}
} // bool ReadScriptDescriptor::_CheckDataType(int32 type, luabind::object& obj_check)
开发者ID:segafan,项目名称:Hero-of-Allacrost,代码行数:56,代码来源:script_read.cpp

示例15: addFromList

void WaypointList::addFromList(const luabind::object &list) {
    if (list.is_valid()) {
        if (luabind::type(list) == LUA_TTABLE) {
            for (luabind::iterator it(list), end; it != end; ++it) {
                position pos = luabind::object_cast<position>(*it);
                positions.push_back(pos);
            }
        }
    }
}
开发者ID:GNoone,项目名称:Illarion-Server,代码行数:10,代码来源:WaypointList.cpp


注:本文中的luabind::object类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。