亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? class_rep_scope.hpp

?? 國外魔獸世界-NOPserver源碼,2004年版
?? HPP
?? 第 1 頁 / 共 3 頁
字號:
// Copyright (c) 2003 Daniel Wallin and Arvid Norberg

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.


#ifndef LUABIND_CLASS_REP_HPP_INCLUDED
#define LUABIND_CLASS_REP_HPP_INCLUDED

//#include <cstdlib>

#include <boost/limits.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>

#include <luabind/config.hpp>
#include <luabind/detail/object_rep.hpp>
#include <luabind/detail/construct_rep.hpp>
#include <luabind/detail/method_rep.hpp>
#include <luabind/detail/garbage_collector.hpp>
#include <luabind/detail/operator_id.hpp>
#include <luabind/detail/signature_match.hpp>
#include <luabind/detail/class_registry.hpp>
#include <luabind/detail/find_best_match.hpp>
#include <luabind/detail/get_overload_signature.hpp>
#include <luabind/detail/error.hpp>

namespace luabind
{

	template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(LUABIND_MAX_BASES, class A, detail::null_type)>
	struct bases {};
	typedef bases<detail::null_type> no_bases;

	struct class_base;

}

namespace luabind { namespace detail
{
	std::string stack_content_by_name(lua_State* L, int start_index);
	int construct_lua_class_callback(lua_State* L);

	// this is class-specific information, poor man's vtable
	// this is allocated statically (removed by the compiler)
	// a pointer to this structure is stored in the lua tables'
	// metatable with the name __classrep
	// it is used when matching parameters to function calls
	// to determine possible implicit casts
	// it is also used when finding the best match for overloaded
	// methods
	class class_rep
	{
	friend struct luabind::class_base;
	friend int super_callback(lua_State*);
//TODO: avoid the lua-prefix
	friend int lua_class_gettable(lua_State*);
	friend int lua_class_settable(lua_State*);
	friend int static_class_gettable(lua_State*);
	public:

		enum class_type
		{
			cpp_class = 0,
			lua_class = 1
		};

		// destructor is a lua callback function that is hooked as garbage collector event on every instance
		// of this class (including those that is not owned by lua). It gets an object_rep as argument
		// on the lua stack. It should delete the object pointed to by object_rep::ptr if object_pre::flags
		// is object_rep::owner (which means that lua owns the object)

		// EXPECTS THE TOP VALUE ON THE LUA STACK TO
		// BE THE USER DATA WHERE THIS CLASS IS BEING
		// INSTANTIATED!
		class_rep(LUABIND_TYPE_INFO t, const char* name, lua_State* L, void(*destructor)(void*), LUABIND_TYPE_INFO held_t, void*(*extractor)(void*))
			: m_type(t)
			, m_held_type(held_t)
			, m_extract_underlying_fun(extractor)
			, m_name(name)
			, m_class_type(cpp_class)
			, m_destructor(destructor)
		{

			// TODO: don't we need to copy the name?
			class_registry* r = class_registry::get_registry(L);
			assert((r->cpp_class() != LUA_NOREF) && "you must call luabind::open()"); // you must call luabind::open()

			detail::getref(L, r->cpp_class());
			lua_setmetatable(L, -2);

			lua_pushvalue(L, -1); // duplicate our user data
			m_self_ref = detail::ref(L); // pop one of them

			m_instance_metatable = r->cpp_instance();
		}

		// used when creating a lua class
		// EXPECTS THE TOP VALUE ON THE LUA STACK TO
		// BE THE USER DATA WHERE THIS CLASS IS BEING
		// INSTANTIATED!
		class_rep(lua_State* L, const char* name)
			: m_type(LUABIND_TYPEID(int))
			, m_held_type(0)
			, m_extract_underlying_fun(0)
			, m_name(name)
			, m_class_type(lua_class)
		{
			// TODO: don't we need to copy the name?
			lua_newtable(L);
			m_table_ref = detail::ref(L);

			class_registry* r = class_registry::get_registry(L);
			assert((r->cpp_class() != LUA_NOREF) && "you must call luabind::open()"); // you must call luabind::open()

			detail::getref(L, r->lua_class());
			lua_setmetatable(L, -2);
			lua_pushvalue(L, -1); // duplicate our user data
			m_self_ref = detail::ref(L); // pop one of them

			m_instance_metatable = r->lua_instance();
		}

		~class_rep()
		{
#ifndef LUABIND_DONT_COPY_STRINGS
			for (std::vector<char*>::iterator i = m_strings.begin(); i != m_strings.end(); ++i)
			{
				delete[] *i;
			}
#endif
		}


		// called from the metamethod for __index
		// the object pointer is passed on the lua stack
		int gettable(lua_State* L)
		{
			if (lua_isnil(L, 2))
			{
				lua_pushnil(L);
				return 1;
			}

			// we have to ignore the first argument since this may point to
			// a method that is not present in this class (but in a subclass)
			const char* key = lua_tostring(L, 2);
			std::map<const char*, method_rep, ltstr>::iterator i = m_methods.find(key);
			if (i != m_methods.end())
			{
				// the name is a method, return it
				lua_pushlightuserdata(L, &i->second);
				lua_pushcclosure(L, function_dispatcher, 1);
				return 1;
			}

			std::map<const char*, callback, ltstr>::iterator j = m_getters.find(key);
			if (j != m_getters.end())
			{
				// the name is a data member
				return j->second.func(L, j->second.pointer_offset);
			}

			lua_pushnil(L);
			return 1;
		}

		// called from the metamethod for __newindex
		// the object pointer is passed on the lua stack
		bool settable(lua_State* L)
		{
			if (lua_isnil(L, 2))
			{
				return false;
			}

			// we have to ignore the first argument since this may point to
			// a method that is not present in this class (but in a subclass)
			const char* key = lua_tostring(L, 2);
			std::map<const char*, callback, ltstr>::iterator j = m_setters.find(key);
			if (j != m_setters.end())
			{
				// the name is a data member
				j->second.func(L, j->second.pointer_offset);
				return true;
			}

			return false; // false means that we don't have a member with the given name
		}

		// this is called as __index metamethod on every instance of this class
		static int gettable_dispatcher(lua_State* L)
		{
			object_rep* obj = static_cast<object_rep*>(lua_touserdata(L, 1));
			return obj->crep()->gettable(L);
		}

		// this is called as __newindex metamethod on every instance of this class
		static int settable_dispatcher(lua_State* L)
		{
			object_rep* obj = static_cast<object_rep*>(lua_touserdata(L, 1));

			bool success = obj->crep()->settable(L);

#ifndef LUABIND_NO_ERROR_CHECKING

			if (!success)
			{
				// this block is needed to make sure the std::string is destructed before
				// lua_error() is called
#ifdef BOOST_MSVC
				{
					// msvc has a bug which deletes the string twice, that's
					// why we have to create it on the heap
					std::string* msg = new std::string("cannot set attribute '");
					*msg += obj->crep()->m_name;
					*msg += ".";
					*msg += lua_tostring(L, -2);
					*msg += "'";
					lua_pushstring(L, msg->c_str());
					delete msg;
				}
#else
				{
					std::string msg = "cannot set attribute '";
					msg += obj->crep()->m_name;
					msg += ".";
					msg += lua_tostring(L, -2);
					msg += "'";
					lua_pushstring(L, msg.c_str());
				}
#endif
				lua_error(L);
			}

#endif

			return 0;
		}

		static int operator_dispatcher(lua_State* L)
		{
			int id = static_cast<int>(lua_tonumber(L, lua_upvalueindex(1)));

			int operand_id = 0;

			object_rep* operand[2];
			for (int i = 0; i < 2; ++i)
				operand[i] = detail::is_class_object(L, i + 1);

			if (operand[0] && operand[1])
				if (LUABIND_TYPE_INFO_EQUAL(operand[0]->crep()->type(), operand[1]->crep()->type())) operand[1] = 0;

			std::vector<operator_callback>* overloads[2];
			for (int i = 0; i < 2; ++i)
				if (operand[i]) overloads[i] = &operand[i]->crep()->m_operators[id]; else overloads[i] = 0;

			std::size_t num_overloads[2];
			for (int i = 0; i < 2; ++i)
				if (overloads[i]) num_overloads[i] = overloads[i]->size(); else num_overloads[i] = 0;

			bool ambiguous = false;
			int match_index = -1;
			int min_match = std::numeric_limits<int>::max();

//			std::cout << "operator_dispatcher\n";
//			std::cout << "num overloads: " << num_overloads[0] + num_overloads[1] << "\n";
//			std::cout << "operator: " << id << "\n";

#ifdef LUABIND_NO_ERROR_CHECKING

			if (num_overloads[0] == 1 && num_overloads[1] == 0)
			{
				operand_id = 0;
				match_index = 0;
			}
			else if (num_overloads[0] == 0 && num_overloads[1] == 1)
			{
				operand_id = 1;
				match_index = 0;
			}
			else
			{

#endif

				int num_params = lua_gettop(L);
				if (overloads[0])
				{
					if (find_best_match(L, overloads[0]->begin(), overloads[0]->end(), ambiguous, min_match, match_index, num_params))
						operand_id = 0;
				}

				// have look at the right operand.
				// if the right operand is a class and
				// not the same class as this, we have to
				// try to match it's operators too	

				if (overloads[1])
				{
					if(find_best_match(L, overloads[1]->begin(), overloads[1]->end(), ambiguous, min_match, match_index, num_params))
						operand_id = 1;
				}

#ifdef LUABIND_NO_ERROR_CHECKING

			}

#else

			if (match_index == -1)
			{
				// this block is needed to make sure the std::string is destructed before
				// lua_error() is called
				{
					std::string msg = "no operator ";
					msg += get_operator_symbol(id);
					msg += " matched the arguments (";
					msg += stack_content_by_name(L, 1);
					msg += ")\ncandidates are:\n";

					if (overloads[0])
						msg += get_overload_signatures(L, overloads[0]->begin(), overloads[0]->end(), get_operator_symbol(id));

					if (overloads[1])
						msg += get_overload_signatures(L, overloads[1]->begin(), overloads[1]->end(), get_operator_symbol(id));
					
					lua_pushstring(L, msg.c_str());
				}
				lua_error(L);
			}
			else if (ambiguous)
			{
				// this block is needed to make sure the std::string is destructed before
				// lua_error() is called
				{
					std::string msg = "call of overloaded operator ";
					msg += get_operator_symbol(id);
					msg += " (";
					msg += stack_content_by_name(L, 1);
					msg += ")' is ambiguous\nnone of the overloads have a best conversion:\n";

					std::vector<operator_callback> candidates;
					if (overloads[0])
						find_exact_match(L, overloads[0]->begin(), overloads[0]->end(), min_match, num_params, candidates);

					if (overloads[1])
						find_exact_match(L, overloads[1]->begin(), overloads[1]->end(), min_match, num_params, candidates);

					msg += get_overload_signatures(L, candidates.begin(), candidates.end(), get_operator_symbol(id));


					lua_pushstring(L, msg.c_str());
				}
				lua_error(L);
			}

#endif

			return (*overloads[operand_id])[match_index].call(L);
		}


		// this is called as metamethod __call on the class_rep.
		static int constructor_dispatcher(lua_State* L)
		{
			class_rep* crep = static_cast<class_rep*>(lua_touserdata(L, 1));
			construct_rep* rep = &crep->m_constructor;

			bool ambiguous = false;
			int match_index = -1;
			int min_match = std::numeric_limits<int>::max();
			bool found;

#ifdef LUABIND_NO_ERROR_CHECKING

			if (rep->overloads.size() == 1)
			{
				match_index = 0;
			}
			else
			{

#endif

				int num_params = lua_gettop(L) - 1;
				found = find_best_match(L, rep->overloads.begin(), rep->overloads.end(), ambiguous, min_match, match_index, num_params);

#ifdef LUABIND_NO_ERROR_CHECKING

			}

#else

			if (!found)
			{
				// this block is needed to make sure the std::string is destructed before
				// lua_error() is called
				{
					std::string msg = "no constructor of '";
					msg += crep->name();
					msg += "' matched the arguments (";
					msg += stack_content_by_name(L, 2);
					msg += ")\n candidates are:\n";

					msg += get_overload_signatures(L, rep->overloads.begin(), rep->overloads.end(), crep->name());

					lua_pushstring(L, msg.c_str());
				}
				lua_error(L);
			}
			else if (ambiguous)
			{
				// this block is needed to make sure the std::string is destructed before
				// lua_error() is called
				{
					std::string msg = "call of overloaded constructor '";
					msg += crep->m_name;
					msg +=  "(";
					msg += stack_content_by_name(L, 2);
					msg += ")' is ambiguous\nnone of the overloads have a best conversion:\n";

					std::vector<construct_rep::overload_t> candidates;
					find_exact_match(L, rep->overloads.begin(), rep->overloads.end(), min_match, num_params, candidates);
					msg += get_overload_signatures(L, candidates.begin(), candidates.end(), crep->name());

					lua_pushstring(L, msg.c_str());
				}
				lua_error(L);
			}

#endif

#ifndef LUABIND_NO_EXCEPTIONS

			try
			{

#endif

				void* object_ptr = rep->overloads[match_index].construct(L);

				void* obj_rep = lua_newuserdata(L, sizeof(object_rep));
				new(obj_rep) object_rep(object_ptr, crep, object_rep::owner, crep->destructor());

				detail::getref(L, crep->m_instance_metatable);
				lua_setmetatable(L, -2);
				return 1;

#ifndef LUABIND_NO_EXCEPTIONS

			}

			catch(const std::exception& e)
			{
				lua_pushstring(L, e.what());
			}
			catch(const char* s)
			{
				lua_pushstring(L, s);
			}
			catch(...)
			{
				{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频在线永久播放| 一区二区三区免费| 一区二区三区欧美日韩| 蜜臀国产一区二区三区在线播放 | 91.com在线观看| 中文字幕欧美区| 亚洲国产日韩综合久久精品| 国产成人精品免费视频网站| 欧美精品1区2区3区| 国产精品传媒在线| 国产在线观看一区二区| 欧美日韩久久一区二区| 中文字幕一区二区三区不卡在线| 另类成人小视频在线| 欧美午夜精品久久久久久孕妇| 国产亚洲污的网站| 日本不卡123| 欧美日韩亚洲丝袜制服| 一区二区三区四区精品在线视频| 成人听书哪个软件好| 精品处破学生在线二十三| 免费在线看成人av| 欧美喷潮久久久xxxxx| 一区二区三区.www| 色婷婷精品久久二区二区蜜臂av| 国产午夜久久久久| 国产一区视频导航| 久久蜜桃av一区精品变态类天堂| 日本不卡的三区四区五区| 91精品国产综合久久小美女| 五月激情丁香一区二区三区| 欧美在线视频你懂得| 一区二区三区在线观看欧美| 色婷婷亚洲精品| 亚洲欧美日韩小说| 色老汉一区二区三区| 亚洲精品久久7777| 欧美性大战久久久久久久蜜臀| 国产精品传媒视频| 色综合久久天天综合网| 亚洲欧美精品午睡沙发| 色狠狠av一区二区三区| 亚洲网友自拍偷拍| 欧美一区永久视频免费观看| 日本女优在线视频一区二区| 日韩欧美高清dvd碟片| 国产一区视频网站| 中文字幕一区不卡| 欧美无砖专区一中文字| 免费高清在线视频一区·| 精品国产伦理网| av男人天堂一区| 一区二区三区在线免费| 欧美久久久久久蜜桃| 国产呦萝稀缺另类资源| 国产视频一区二区三区在线观看| 99re在线精品| 三级久久三级久久久| 亚洲精品在线免费观看视频| 成人免费精品视频| 亚洲国产成人tv| 久久久久九九视频| 91偷拍与自偷拍精品| 日韩不卡一区二区三区| 中文字幕+乱码+中文字幕一区| 色悠悠久久综合| 麻豆91精品视频| 亚洲女同一区二区| 日韩精品专区在线| 91麻豆免费看片| 久草中文综合在线| 一区二区三区久久久| 精品日韩99亚洲| 日本韩国欧美一区| 国产一区二区三区在线观看免费| 1024成人网| 精品久久久三级丝袜| 色婷婷一区二区三区四区| 极品美女销魂一区二区三区免费| 亚洲欧洲精品一区二区三区不卡 | 99热99精品| 日韩精品一二区| 国产精品久久久久永久免费观看| 欧美一区二区三区免费视频| 91色porny蝌蚪| 激情综合网最新| 亚洲成a天堂v人片| 国产精品久久久久久亚洲毛片| 日韩欧美中文字幕制服| 91成人免费在线| 99精品欧美一区二区三区小说| 日韩av不卡一区二区| 亚洲欧洲制服丝袜| 国产三级欧美三级| 精品国产91亚洲一区二区三区婷婷| 91麻豆国产精品久久| 国产剧情av麻豆香蕉精品| 性久久久久久久久久久久| 国产精品护士白丝一区av| 精品国产成人在线影院 | 91亚洲精品一区二区乱码| 久久99久久99小草精品免视看| 亚洲综合色噜噜狠狠| 国产精品久久99| 久久久亚洲综合| 精品久久五月天| 日韩欧美激情四射| 日韩三级视频在线观看| 91麻豆精品国产自产在线| 色婷婷综合久久久久中文一区二区 | 国产午夜精品美女毛片视频| 欧美一区二区免费视频| 在线播放视频一区| 欧美日韩精品欧美日韩精品一| 91美女视频网站| 色一情一乱一乱一91av| 91日韩一区二区三区| 99国产精品久久久久久久久久久| 国产成人高清在线| 成人深夜在线观看| 高清成人免费视频| 国产.欧美.日韩| 丁香婷婷深情五月亚洲| 成人毛片老司机大片| 成人黄色电影在线| 色综合欧美在线| 欧美亚洲国产bt| 欧美美女视频在线观看| 欧美一区二区三区在线观看| 日韩一区二区三区电影| 久久这里只有精品视频网| 久久精品在这里| 国产精品久99| 亚洲国产综合91精品麻豆| 日韩精品国产精品| 国产一区日韩二区欧美三区| 成人一区二区三区视频在线观看| 成人a级免费电影| 91福利国产精品| 日韩欧美黄色影院| 中国色在线观看另类| 亚洲美女一区二区三区| 亚洲午夜精品17c| 久久99精品国产.久久久久久 | 成人免费毛片app| 欧美性一区二区| 精品国产一区二区三区忘忧草| 久久久.com| 亚洲一区二区黄色| 久久99最新地址| 91啪在线观看| 欧美一二三四区在线| 国产精品色一区二区三区| 亚洲 欧美综合在线网络| 韩国欧美国产1区| 色久综合一二码| 久久一区二区视频| 亚洲一区二区精品视频| 国产精品一二三| 欧美性大战久久久久久久| 久久久久青草大香线综合精品| 亚洲精品第一国产综合野| 狠狠色狠狠色合久久伊人| 91网上在线视频| 国产色产综合产在线视频| 亚洲一区二区三区小说| 国产伦精一区二区三区| 欧美无砖专区一中文字| 国产精品国产三级国产三级人妇| 日本亚洲三级在线| 91麻豆国产精品久久| 久久久亚洲高清| 五月天久久比比资源色| 99久久99久久久精品齐齐| 日韩欧美一二区| 亚洲成人在线免费| 色综合天天综合给合国产| 精品国产露脸精彩对白| 亚洲第一在线综合网站| 91麻豆swag| 国产精品久久久久一区二区三区共| 美女视频黄久久| 欧美高清性hdvideosex| 亚洲精品国产视频| 91视频在线看| 欧美激情一区二区三区蜜桃视频| 蓝色福利精品导航| 91.com视频| 三级一区在线视频先锋| 精品视频一区二区三区免费| 亚洲视频免费在线| 丰满放荡岳乱妇91ww| 国产色婷婷亚洲99精品小说| 韩国v欧美v亚洲v日本v| 日韩三区在线观看| 久久99精品一区二区三区| 日韩女同互慰一区二区| 美国欧美日韩国产在线播放| 欧美一级黄色片| 精品写真视频在线观看|