DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// 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_POLICY_HPP_INCLUDED #define LUABIND_POLICY_HPP_INCLUDED #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace luabind { namespace detail { struct conversion_policy_base {}; } template
struct conversion_policy : detail::conversion_policy_base { BOOST_STATIC_CONSTANT(int, index = N); BOOST_STATIC_CONSTANT(bool, has_arg = HasArg); }; class index_map { public: index_map(const int* m): m_map(m) {} int operator[](int index) const { return m_map[index]; } private: const int* m_map; }; namespace converters { using luabind::detail::yes_t; using luabind::detail::no_t; using luabind::detail::by_value; using luabind::detail::by_reference; using luabind::detail::by_const_reference; using luabind::detail::by_pointer; using luabind::detail::by_const_pointer; no_t is_user_defined(...); } namespace detail { template
struct is_user_defined { BOOST_STATIC_CONSTANT(bool, value = sizeof(luabind::converters::is_user_defined(LUABIND_DECORATE_TYPE(T))) == sizeof(yes_t)); }; LUABIND_API int implicit_cast(const class_rep* crep, LUABIND_TYPE_INFO const&, int& pointer_offset); } // template
class functor; class weak_ref; } namespace luabind { namespace detail { template
struct is_primitive; /* template
yes_t is_lua_functor_test(const functor
&); #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) no_t is_lua_functor_test(...); #else template
no_t is_lua_functor_test(const T&); #endif template
struct is_lua_functor { static T t; BOOST_STATIC_CONSTANT(bool, value = sizeof(is_lua_functor_test(t)) == sizeof(yes_t)); }; */ template
struct policy_cons { typedef H head; typedef T tail; template
policy_cons
> operator,(policy_cons
) { return policy_cons
>(); } template
policy_cons
> operator+(policy_cons
) { return policy_cons
>(); } template
policy_cons
> operator|(policy_cons
) { return policy_cons
>(); } }; struct indirection_layer { template
indirection_layer(const T&); }; yes_t is_policy_cons_test(const null_type&); template
yes_t is_policy_cons_test(const policy_cons
&); no_t is_policy_cons_test(...); template
struct is_policy_cons { static const T& t; BOOST_STATIC_CONSTANT(bool, value = sizeof(is_policy_cons_test(t)) == sizeof(yes_t)); typedef boost::mpl::bool_
type; }; template
struct is_string_literal { static no_t helper(indirection_layer); static yes_t helper(const char*); }; template<> struct is_string_literal
{ static no_t helper(indirection_layer); }; template
struct is_primitive/*: boost::mpl::bool_c
*/ { static T t; BOOST_STATIC_CONSTANT(bool, value = sizeof(is_string_literal
::value>::helper(t)) == sizeof(yes_t)); }; #define LUABIND_INTEGER_TYPE(type) \ template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; LUABIND_INTEGER_TYPE(char) LUABIND_INTEGER_TYPE(short) LUABIND_INTEGER_TYPE(int) LUABIND_INTEGER_TYPE(long) template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; \ template<> struct is_primitive
: boost::mpl::true_ {}; \ #undef LUABIND_INTEGER_TYPE template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; // TODO: add more template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template<> struct is_primitive
: boost::mpl::bool_
{}; template
struct primitive_converter; template<> struct primitive_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef primitive_converter type; void apply(lua_State* L, int v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, short v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, char v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, long v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, unsigned int v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, unsigned short v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, unsigned char v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, unsigned long v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, float v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, double v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, long double v) { lua_pushnumber(L, (lua_Number)v); } void apply(lua_State* L, const char* v) { if (v) { lua_pushstring(L, v); } else { lua_pushnil(L); } } void apply(lua_State* L, const std::string& v) { lua_pushlstring(L, v.data(), v.size()); } void apply(lua_State* L, bool b) { lua_pushboolean(L, b); } }; template<> struct primitive_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef primitive_converter type; #define PRIMITIVE_CONVERTER(prim) \ prim apply(lua_State* L, luabind::detail::by_const_reference
, int index) { return apply(L, detail::by_value
(), index); } \ prim apply(lua_State* L, luabind::detail::by_value
, int index) { return apply(L, detail::by_value
(), index); } \ prim apply(lua_State* L, luabind::detail::by_value
, int index) #define PRIMITIVE_MATCHER(prim) \ static int match(lua_State* L, luabind::detail::by_const_reference
, int index) { return match(L, detail::by_value
(), index); } \ static int match(lua_State* L, luabind::detail::by_value
, int index) { return match(L, detail::by_value
(), index); } \ static int match(lua_State* L, luabind::detail::by_value
, int index) PRIMITIVE_CONVERTER(bool) { return lua_toboolean(L, index) == 1; } PRIMITIVE_MATCHER(bool) { if (lua_type(L, index) == LUA_TBOOLEAN) return 0; else return -1; } PRIMITIVE_CONVERTER(int) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(int) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(unsigned int) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(unsigned int) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(char) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(char) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(signed char) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(signed char) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(unsigned char) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(unsigned char) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(short) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(short) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(unsigned short) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(unsigned short) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(long) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(long) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(unsigned long) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(unsigned long) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(float) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(float) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(double) { return static_cast
(lua_tonumber(L, index)); } PRIMITIVE_MATCHER(double) { if (lua_type(L, index) == LUA_TNUMBER) return 0; else return -1; } PRIMITIVE_CONVERTER(lua_State*) { return lua_tothread(L, index); } PRIMITIVE_MATCHER(lua_State*) { if (lua_type(L, index) == LUA_TTHREAD) return 0; else return -1; } PRIMITIVE_CONVERTER(std::string) { return std::string(lua_tostring(L, index), lua_strlen(L, index)); } PRIMITIVE_MATCHER(std::string) { if (lua_type(L, index) == LUA_TSTRING) return 0; else return -1; } PRIMITIVE_CONVERTER(luabind::weak_ref) { LUABIND_CHECK_STACK(L); return luabind::weak_ref(L, index); } PRIMITIVE_MATCHER(luabind::weak_ref) { (void)index; (void)L; return (std::numeric_limits
::max)() - 1; } const char* apply(lua_State* L, detail::by_const_pointer
, int index) { return static_cast
(lua_tostring(L, index)); } const char* apply(lua_State* L, detail::by_const_pointer
, int index) { return static_cast
(lua_tostring(L, index)); } static int match(lua_State* L, by_const_pointer
, int index) { return lua_type(L, index) == LUA_TSTRING || lua_isnil(L, index) ? 0 : -1; } static int match(lua_State* L, by_const_pointer
, int index) { return lua_type(L, index) == LUA_TSTRING || lua_isnil(L, index) ? 0 : -1; } template
void converter_postcall(lua_State*, T, int) {} #undef PRIMITIVE_MATCHER #undef PRIMITIVE_CONVERTER }; // ********** user defined converter *********** template
struct user_defined_converter; template<> struct user_defined_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef user_defined_converter type; template
T apply(lua_State* L, detail::by_value
, int index) { using namespace converters; return convert_lua_to_cpp(L, detail::by_value
(), index); } template
T apply(lua_State* L, detail::by_reference
, int index) { using namespace converters; return convert_lua_to_cpp(L, detail::by_reference
(), index); } template
T apply(lua_State* L, detail::by_const_reference
, int index) { using namespace converters; return convert_lua_to_cpp(L, detail::by_const_reference
(), index); } template
T* apply(lua_State* L, detail::by_pointer
, int index) { using namespace converters; return convert_lua_to_cpp(L, detail::by_pointer
(), index); } template
const T* apply(lua_State* L, detail::by_const_pointer
, int index) { using namespace converters; return convert_lua_to_cpp(L, detail::by_pointer
(), index); } template
static int match(lua_State* L, T, int index) { using namespace converters; return match_lua_to_cpp(L, T(), index); } template
void converter_postcall(lua_State*, T, int) {} }; template<> struct user_defined_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef user_defined_converter type; template
void apply(lua_State* L, const T& v) { using namespace converters; convert_cpp_to_lua(L, v); } }; // ********** pointer converter *********** template
struct pointer_converter; template<> struct pointer_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef pointer_converter type; template
void apply(lua_State* L, T* ptr) { if (ptr == 0) { lua_pushnil(L); return; } if (luabind::get_back_reference(L, ptr)) return; class_rep* crep = get_class_rep
(L); // if you get caught in this assert you are // trying to use an unregistered type assert(crep && "you are trying to use an unregistered type"); // create the struct to hold the object void* obj = lua_newuserdata(L, sizeof(object_rep)); //new(obj) object_rep(ptr, crep, object_rep::owner, destructor_s
::apply); new(obj) object_rep(ptr, crep, 0, 0); // set the meta table detail::getref(L, crep->metatable_ref()); lua_setmetatable(L, -2); } }; template
struct make_pointer { typedef T* type; }; template<> struct pointer_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef pointer_converter type; // TODO: does the pointer converter need this?! char target[32]; void (*destructor)(void *); pointer_converter(): destructor(0) {} template
typename make_pointer
::type apply(lua_State* L, by_pointer
, int index) { // preconditions: // lua_isuserdata(L, index); // getmetatable().__lua_class is true // object_rep->flags() & object_rep::constant == 0 if (lua_isnil(L, index)) return 0; object_rep* obj = static_cast
(lua_touserdata(L, index)); assert((obj != 0) && "internal error, please report"); // internal error const class_rep* crep = obj->crep(); T* ptr = reinterpret_cast
(crep->convert_to(LUABIND_TYPEID(T), obj, target)); if ((void*)ptr == (char*)target) destructor = detail::destruct_only_s
::apply; assert(!destructor || sizeof(T) <= 32); return ptr; } template
static int match(lua_State* L, by_pointer
, int index) { if (lua_isnil(L, index)) return 0; object_rep* obj = is_class_object(L, index); if (obj == 0) return -1; // cannot cast a constant object to nonconst if (obj->flags() & object_rep::constant) return -1; if ((LUABIND_TYPE_INFO_EQUAL(obj->crep()->holder_type(), LUABIND_TYPEID(T)))) return (obj->flags() & object_rep::constant)?-1:0; if ((LUABIND_TYPE_INFO_EQUAL(obj->crep()->const_holder_type(), LUABIND_TYPEID(T)))) return (obj->flags() & object_rep::constant)?0:-1; int d; return implicit_cast(obj->crep(), LUABIND_TYPEID(T), d); } ~pointer_converter() { if (destructor) destructor(target); } template
void converter_postcall(lua_State*, by_pointer
, int) {} }; // ******* value converter ******* template
struct value_converter; template<> struct value_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef value_converter type; template
void apply(lua_State* L, const T& ref) { if (luabind::get_back_reference(L, ref)) return; class_rep* crep = get_class_rep
(L); // if you get caught in this assert you are // trying to use an unregistered type assert(crep && "you are trying to use an unregistered type"); void* obj_rep; void* held; boost::tie(obj_rep,held) = crep->allocate(L); void* object_ptr; void(*destructor)(void*); destructor = crep->destructor(); int flags = object_rep::owner; if (crep->has_holder()) { new(held) T(ref); object_ptr = held; if (LUABIND_TYPE_INFO_EQUAL(LUABIND_TYPEID(T), crep->const_holder_type())) { flags |= object_rep::constant; destructor = crep->const_holder_destructor(); } } else { object_ptr = new T(ref); } new(obj_rep) object_rep(object_ptr, crep, flags, destructor); // set the meta table detail::getref(L, crep->metatable_ref()); lua_setmetatable(L, -2); } }; template
struct make_const_reference { typedef const T& type; }; template
struct destruct_guard { T* ptr; bool dismiss; destruct_guard(T* p): ptr(p), dismiss(false) {} ~destruct_guard() { if (!dismiss) ptr->~T(); } }; template<> struct value_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef value_converter type; template
T apply(lua_State* L, by_value
, int index) { // preconditions: // lua_isuserdata(L, index); // getmetatable().__lua_class is true // object_rep->flags() & object_rep::constant == 0 object_rep* obj = 0; const class_rep* crep = 0; // special case if we get nil in, try to convert the holder type if (lua_isnil(L, index)) { crep = get_class_rep
(L); assert(crep); } else { obj = static_cast
(lua_touserdata(L, index)); assert((obj != 0) && "internal error, please report"); // internal error crep = obj->crep(); } assert(crep); // TODO: align! char target[sizeof(T)]; T* ptr = reinterpret_cast
(crep->convert_to(LUABIND_TYPEID(T), obj, target)); destruct_guard
guard(ptr); if ((void*)ptr != (void*)target) guard.dismiss = true; return *ptr; } template
static int match(lua_State* L, by_value
, int index) { // special case if we get nil in, try to match the holder type if (lua_isnil(L, index)) { class_rep* crep = get_class_rep
(L); if (crep == 0) return -1; if ((LUABIND_TYPE_INFO_EQUAL(crep->holder_type(), LUABIND_TYPEID(T)))) return 0; if ((LUABIND_TYPE_INFO_EQUAL(crep->const_holder_type(), LUABIND_TYPEID(T)))) return 0; return -1; } object_rep* obj = is_class_object(L, index); if (obj == 0) return -1; int d; if ((LUABIND_TYPE_INFO_EQUAL(obj->crep()->holder_type(), LUABIND_TYPEID(T)))) return (obj->flags() & object_rep::constant)?-1:0; if ((LUABIND_TYPE_INFO_EQUAL(obj->crep()->const_holder_type(), LUABIND_TYPEID(T)))) return (obj->flags() & object_rep::constant)?0:1; return implicit_cast(obj->crep(), LUABIND_TYPEID(T), d); } template
void converter_postcall(lua_State*, T, int) {} }; // ******* const pointer converter ******* template
struct const_pointer_converter; template<> struct const_pointer_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef const_pointer_converter type; template
void apply(lua_State* L, const T* ptr) { if (ptr == 0) { lua_pushnil(L); return; } if (luabind::get_back_reference(L, ptr)) return; class_rep* crep = get_class_rep
(L); // if you get caught in this assert you are // trying to use an unregistered type assert(crep && "you are trying to use an unregistered type"); // create the struct to hold the object void* obj = lua_newuserdata(L, sizeof(object_rep)); assert(obj && "internal error, please report"); // we send 0 as destructor since we know it will never be called new(obj) object_rep(const_cast
(ptr), crep, object_rep::constant, 0); // set the meta table detail::getref(L, crep->metatable_ref()); lua_setmetatable(L, -2); } }; template
struct make_const_pointer { typedef const T* type; }; template<> struct const_pointer_converter
: private pointer_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef const_pointer_converter type; template
typename make_const_pointer
::type apply(lua_State* L, by_const_pointer
, int index) { return pointer_converter
::apply(L, by_pointer
(), index); } template
static int match(lua_State* L, by_const_pointer
, int index) { if (lua_isnil(L, index)) return 0; object_rep* obj = is_class_object(L, index); if (obj == 0) return -1; // if the type is not one of our own registered types, classify it as a non-match if ((LUABIND_TYPE_INFO_EQUAL(obj->crep()->holder_type(), LUABIND_TYPEID(T)))) return (obj->flags() & object_rep::constant)?-1:0; if ((LUABIND_TYPE_INFO_EQUAL(obj->crep()->const_holder_type(), LUABIND_TYPEID(T)))) return (obj->flags() & object_rep::constant)?0:1; bool const_ = obj->flags() & object_rep::constant; int d; int points = implicit_cast(obj->crep(), LUABIND_TYPEID(T), d); return points == -1 ? -1 : points + !const_; } template
void converter_postcall(lua_State* L, by_const_pointer
, int index) { pointer_converter
::converter_postcall(L, by_pointer
(), index); } }; // ******* reference converter ******* template
struct ref_converter; template<> struct ref_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef ref_converter type; template
void apply(lua_State* L, T& ref) { if (luabind::get_back_reference(L, ref)) return; class_rep* crep = get_class_rep
(L); // if you get caught in this assert you are // trying to use an unregistered type assert(crep && "you are trying to use an unregistered type"); T* ptr = &ref; // create the struct to hold the object void* obj = lua_newuserdata(L, sizeof(object_rep)); assert(obj && "internal error, please report"); new(obj) object_rep(ptr, crep, 0, 0); // set the meta table detail::getref(L, crep->metatable_ref()); lua_setmetatable(L, -2); } }; template
struct make_reference { typedef T& type; }; template<> struct ref_converter
{ typedef boost::mpl::bool_
is_value_converter; typedef ref_converter type; template
typename make_reference
::type apply(lua_State* L, by_reference
, int index) { assert(!lua_isnil(L, index)); return *pointer_converter
().apply(L, by_pointer
(), index); } template
static int match(lua_State* L, by_reference
, int index) { if (lua_isnil(L, index)) return -1; return pointer_converter
::match(L, by_pointer
(), index); } template