x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
property.hpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\luabind\luabind\detail\property.hpp
Girar
Efecto
Propiedad
Historial
// 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
Dirección de la página
Dirección del archivo
Anterior
38/43
Siguiente
Descargar
( 7 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.