x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
property.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\luabind\luabind\detail\property.hpp
旋转
特效
属性
历史版本
// 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_PROPERTY_HPP_INCLUDED #define LUABIND_PROPERTY_HPP_INCLUDED #include
#include
#include
#include
#include
#include
namespace luabind { namespace detail { namespace mpl = boost::mpl; class object_rep; /* template
int get(R(T::*f)() const, T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } template
int get(R(*f)(const T*), T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } template
int get(R(*f)(const T&), T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } */ template
int get(R(C::*f)() const, T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } template
int get(R(*f)(T), U* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } template
struct get_caller : Policies { get_caller() {} get_caller(const Policies& p): Policies(p) {} int operator()(lua_State* L, int pointer_offset, F f) { // parameters on the lua stack: // 1. object_rep // 2. key (property name) return get(f, (T*)0, L, static_cast
(this)); } }; template
int set(R(C::*f)(A1), T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } /* template
int set(void(*f)(T*, A1), T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } template
int set(void(*f)(T&, A1), T* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } */ template
int set(R(*f)(T, A1), U* obj, lua_State* L, Policies* policies) { return returns
::call(f, obj, L, policies); } template
struct set_caller : Policies { int operator()(lua_State* L, int pointer_offset, F f) { // parameters on the lua stack: // 1. object_rep // 2. key (property name) // 3. value // and since call() expects it's first // parameter on index 2 we need to // remove the key-parameter (parameter 2). lua_remove(L, 2); return luabind::detail::set(f, (T*)0, L, static_cast
(this)); } }; typedef int (*match_fun_ptr)(lua_State*, int); template
struct set_matcher { static int apply(lua_State* L, int index) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typedef typename mpl::apply_wrap2
::type converter; return converter::match(L, LUABIND_DECORATE_TYPE(T), index); } }; template
match_fun_ptr gen_set_matcher(void (*)(T, Param), Policy*) { return set_matcher
::apply; } template
match_fun_ptr gen_set_matcher(void (T::*)(Param), Policy*) { return set_matcher
::apply; } template
struct auto_set : Policies { auto_set() {} auto_set(const Policies& p): Policies(p) {} int operator()(lua_State* L, int pointer_offset, D T::*member) { int nargs = lua_gettop(L); // parameters on the lua stack: // 1. object_rep // 2. key (property name) // 3. value object_rep* obj = static_cast
(lua_touserdata(L, 1)); class_rep* crep = obj->crep(); void* raw_ptr; if (crep->has_holder()) raw_ptr = crep->extractor()(obj->ptr()); else raw_ptr = obj->ptr(); T* ptr = reinterpret_cast
(static_cast
(raw_ptr) + pointer_offset); typedef typename find_conversion_policy<1,Policies>::type converter_policy; typename mpl::apply_wrap2
::type converter; ptr->*member = converter.apply(L, LUABIND_DECORATE_TYPE(D), 3); int nret = lua_gettop(L) - nargs; const int indices[] = { 1, nargs + nret, 3 }; policy_list_postcall
::apply(L, indices); return nret; } }; // if the input type is a value_converter, it will produce // a reference converter template
struct make_reference_converter { typedef typename mpl::apply_wrap2< ConverterPolicy , typename boost::add_reference
::type , cpp_to_lua >::type type; }; template
struct auto_get : Policies { auto_get() {} auto_get(const Policies& p): Policies(p) {} int operator()(lua_State* L, int pointer_offset, D T::*member) { int nargs = lua_gettop(L); // parameters on the lua stack: // 1. object_rep // 2. key (property name) object_rep* obj = static_cast
(lua_touserdata(L, 1)); class_rep* crep = obj->crep(); void* raw_ptr; if (crep->has_holder()) raw_ptr = crep->extractor()(obj->ptr()); else raw_ptr = obj->ptr(); T* ptr = reinterpret_cast
(static_cast
(raw_ptr) + pointer_offset); typedef typename find_conversion_policy<0,Policies>::type converter_policy; typedef typename mpl::apply_wrap2
::type converter1_t; // if the converter is a valua converer, return a reference instead typedef typename boost::mpl::eval_if< BOOST_DEDUCED_TYPENAME converter1_t::is_value_converter , make_reference_converter
, mpl::identity
>::type converter2_t; // If this yields a reference converter, the dependency policy // is automatically added typedef typename boost::mpl::if_< BOOST_DEDUCED_TYPENAME converter1_t::is_value_converter , policy_cons
, Policies> , Policies >::type policy_list; converter2_t converter; converter.apply(L, ptr->*member); int nret = lua_gettop(L) - nargs; const int indices[] = { 1, nargs + nret }; policy_list_postcall
::apply(L, indices); return nret; } }; }} #endif // LUABIND_PROPERTY_HPP_INCLUDED
property.hpp
网页地址
文件地址
上一页
38/43
下一页
下载
( 7 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.