• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: setGeometryTexture1

void setGeometryTexture1( Geometry * pGeom, const luabind::object & texture1Table )
{
	if ( texture1Table.is_valid() && texture1Table.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_texture1Buffer ) pGeom->m_texture1Buffer.reset( new vector<float> );
		pGeom->m_texture1Buffer->clear();
		for( luabind::object::array_iterator iter = texture1Table.abegin();
			iter != texture1Table.aend();
			iter++ )
		{
			boost::optional<Point2> opt = luabind::object_cast_nothrow<Point2>( *iter );
			if ( opt )
			{
				Point2 * pt = opt.get();
				pGeom->m_texture1Buffer->push_back( pt->x );
				pGeom->m_texture1Buffer->push_back( pt->y );
			}
		}
	}
}
开发者ID:ejabx,项目名称:katana,代码行数:20,代码来源:geometry_script.cpp


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


示例18: setGeometryColor

void setGeometryColor( Geometry * pGeom, const luabind::object & colorTable )
{
	if ( colorTable.is_valid() && colorTable.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_colorBuffer ) pGeom->m_colorBuffer.reset( new vector<float> );
		pGeom->m_colorBuffer->clear();
		for( luabind::object::array_iterator iter = colorTable.abegin();
			iter != colorTable.aend();
			iter++ )
		{
			boost::optional<ColorA> opt = luabind::object_cast_nothrow<ColorA>( *iter );
			if ( opt )
			{
				ColorA * pt = opt.get();
				pGeom->m_colorBuffer->push_back( pt->r );
				pGeom->m_colorBuffer->push_back( pt->g );
				pGeom->m_colorBuffer->push_back( pt->b );
				pGeom->m_colorBuffer->push_back( pt->a );
			}
		}
	}
}
开发者ID:ejabx,项目名称:katana,代码行数:22,代码来源:geometry_script.cpp


示例19: setGeometryVertices

//
// Local Functions
//
void setGeometryVertices( Geometry * pGeom, const luabind::object & vertexTable )
{
	if ( vertexTable.is_valid() && vertexTable.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_vertexBuffer ) pGeom->m_vertexBuffer.reset( new vector<float> );
		pGeom->m_vertexBuffer->clear();
		unsigned uiNewVertices = 0;
		for( luabind::object::array_iterator iter = vertexTable.abegin();
			iter != vertexTable.aend();
			iter++, uiNewVertices++ )
		{
			boost::optional<Point3> opt = luabind::object_cast_nothrow<Point3>( *iter );
			if ( opt )
			{
				Point3 * pt = opt.get();
				pGeom->m_vertexBuffer->push_back( pt->x );
				pGeom->m_vertexBuffer->push_back( pt->y );
				pGeom->m_vertexBuffer->push_back( pt->z );
			}
		}
		pGeom->m_vertexCount = uiNewVertices;
	}
}
开发者ID:ejabx,项目名称:katana,代码行数:26,代码来源:geometry_script.cpp


示例20: RunScriptObject

bool ReadScriptDescriptor::RunScriptObject(const luabind::object& object) {

	// Don't log in that case because we might want to run invalid (empty) objects
	// to simplify the caller code.
	if (!object.is_valid())
		return true;

	try {
	    ScriptCallFunction<void>(object);
	} catch(luabind::error e) {
		PRINT_ERROR << "Error while loading script object." << std::endl;
		ScriptManager->HandleLuaError(e);
		return false;
	}
	return true;
}
开发者ID:rkettering,项目名称:ValyriaTear,代码行数:16,代码来源:script_read.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ luaplus::LuaObject类代码示例发布时间:2022-05-31
下一篇:
C++ lt::session类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap