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


C++ object::pushvalue方法代码示例

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


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

示例1: 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

示例2: sizeof

void print_free_functions				(lua_State *L, const luabind::object &object, LPCSTR header, const xr_string &indent)
{
	u32							count = 0;
	luabind::object::iterator	I = object.begin();
	luabind::object::iterator	E = object.end();
	for ( ; I != E; ++I) {
		if ((*I).type() != LUA_TFUNCTION)
			continue;
		(*I).pushvalue();
		luabind::detail::free_functions::function_rep* rep = 0;
		if (lua_iscfunction(L, -1))
		{
			if (lua_getupvalue(L, -1, 2) != 0)
			{
				// check the magic number that identifies luabind's functions
				if (lua_touserdata(L, -1) == (void*)0x1337)
				{
					if (lua_getupvalue(L, -2, 1) != 0)
					{
						if (!count)
							FastMsg("\n%snamespace %s {",indent.c_str(),header);
						++count;
						rep = static_cast<luabind::detail::free_functions::function_rep*>(lua_touserdata(L, -1));
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	i = rep->overloads().begin();
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	e = rep->overloads().end();
						for ( ; i != e; ++i) {
							xr_string	S;
							(*i).get_signature(L,S);
							FastMsg("    %sfunction %s%s;",indent.c_str(),rep->name(), process_signature(S).c_str());
						}
						lua_pop(L, 1);
					}
				}
				lua_pop(L, 1);
			}
		}
		lua_pop(L, 1);
	}
	{
		static xr_vector<xr_string> nesting_path;

		xr_string				_indent = indent;
		xr_string				last_key = "?";
		_indent.append			("    ");
		
		object.pushvalue();
		int n_table = lua_gettop(L);
		// Msg("# n_table = %d ", n_table);
		lua_pushnil		(L);		
		int save_top = lua_gettop(L);

// #pragma todo("alpet : при загруженной сохраненке здесь иногда происходит сбой invalid key to 'next', а потом креш в недрах Direct3D ")
		while (lua_next(L, n_table) != 0) {  
			last_key = "~"; 
			int key_type = lua_type(L, -2);			
			if (lua_type(L, -1) == LUA_TTABLE && key_type == LUA_TSTRING && lua_objlen(L, -2) > 0) {				
				last_key = lua_tostring(L, -2);
				LPCSTR	S = last_key.c_str();
				MsgCB("~#CONTEXT: last_key = %s", S);
				string_path script_name;
				sprintf_s(script_name, sizeof(script_name) - 1, "%s.script", S);
				if (nesting_path.size() == 0 && // скан глобального пространства имен
					(last_key == "" || last_key == "config" || last_key == "package" || last_key == "jit" || last_key == "loaded" || last_key == "md_list" ||
   					 FS.exist("$game_scripts$", script_name) )) // с дампом экспортируемых luabind вещей, возникают сбои!
				{
					Msg("! skipping namespace %s ", last_key.c_str());
					lua_pop(L, 1);
					continue;
				}
				
				if (xr_strcmp("_G", S)) {					
					luabind::object		object(L);
					object.set();
					// if (!xr_strcmp("security", S)) { S = S; } /// wtf?
					xr_string path_dump = "";
					for (u32 ns = 0; ns < nesting_path.size(); ns++)
						path_dump = path_dump + nesting_path.at(ns) + ".";

					path_dump = path_dump + S;
					Msg("#dumping namespace %s ", path_dump.c_str());
					nesting_path.push_back(S);

					u32 nest_level = nesting_path.size();
					// если слишком много вложений или начали повторяться строки
					if (nest_level < 2 &&
						!(nest_level > 1 && nesting_path.at(0) == S)
						)
					{
						print_free_functions(L, object, S, _indent);
					}
					else
					{
						// problem detected
						Msg("! WARN: to many nested levels for export = %d, or self-reference detected ", nest_level);
						FlushLog();
						dumper->flush();
					}
					nesting_path.pop_back();

				}
//.........这里部分代码省略.........
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:101,代码来源:script_engine_help.cpp

示例3: todo

void print_free_functions				(lua_State *L, const luabind::object &object, LPCSTR header, const xr_string &indent)
{
	u32							count = 0;
	luabind::object::iterator	I = object.begin();
	luabind::object::iterator	E = object.end();
	for ( ; I != E; ++I) {
		if ((*I).type() != LUA_TFUNCTION)
			continue;
		(*I).pushvalue();
		luabind::detail::free_functions::function_rep* rep = 0;
		if (lua_iscfunction(L, -1))
		{
			if (lua_getupvalue(L, -1, 2) != 0)
			{
				// check the magic number that identifies luabind's functions
				if (lua_touserdata(L, -1) == (void*)0x1337)
				{
					if (lua_getupvalue(L, -2, 1) != 0)
					{
						if (!count)
							Msg("\n%snamespace %s {",indent.c_str(),header);
						++count;
						rep = static_cast<luabind::detail::free_functions::function_rep*>(lua_touserdata(L, -1));
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	i = rep->overloads().begin();
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	e = rep->overloads().end();
						for ( ; i != e; ++i) {
							xr_string	S;
							(*i).get_signature(L,S);
							Msg("    %sfunction %s%s;",indent.c_str(),rep->name(),process_signature(S).c_str());
						}
						lua_pop(L, 1);
					}
				}
				lua_pop(L, 1);
			}
		}
		lua_pop(L, 1);
	}
	{
		xr_string				_indent = indent;
		_indent.append			("    ");
		object.pushvalue();
		lua_pushnil		(L);
		while (lua_next(L, -2) != 0) {
			if (lua_type(L, -1) == LUA_TTABLE) {
				if (xr_strcmp("_G",lua_tostring(L, -2))) {
					LPCSTR				S = lua_tostring(L, -2);
					luabind::object		object(L);
					object.set			();
					if (!xr_strcmp("security",S)) {
						S = S;
					}
					print_free_functions(L,object,S,_indent);
				}
			}
#pragma todo("Dima to Dima : Remove this hack if find out why")
			if (lua_isnumber(L,-2)) {
				lua_pop(L,1);
				lua_pop(L,1);
				break;
			}
			lua_pop	(L, 1);
		}
	}
	if (count)
		Msg("%s};",indent.c_str());
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:67,代码来源:script_engine_help.cpp


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