Re: [luabind] Binding splitted between libraries (DLLs)
Brought to you by:
arvidn,
daniel_wallin
From: spam7000 <spa...@o2...> - 2009-07-17 15:05:24
|
I found a solution. Luabind uses address of the type_info structure as returned by typeid operator to detected data type. This type_info structure is created at compile type and put somewhere within the target binary file. When two different libraries (DLLs) loaded into program's address space refer to typeid returned value then each refers to its own copy of the structure. This is why comparing them by address (as done by Luabind) yields inequality. To allow correct type detection across library boundaries I've changed luabind to use type's name returned from type_info::name(). This is slightly slower (strcmp vs pointer compare) but works. Here's a patch for luabind-0.8.1: --- luabind-0.8.1-org/luabind/config.hpp 2009-03-10 10:33:48.000000000 +0100 +++ luabind-0.8.1-string/luabind/config.hpp 2009-07-17 16:46:49.000000000 +0200 @@ -107,10 +107,17 @@ // for all classes that you have type-info for. #ifndef LUABIND_TYPE_INFO +#ifdef LUABIND_TYPE_INFO_STRING + #define LUABIND_TYPE_INFO const char * + #define LUABIND_TYPEID(t) typeid(t).name() + #define LUABIND_TYPE_INFO_EQUAL(i1, i2) strcmp(i1, i2) == 0 + #define LUABIND_INVALID_TYPE_INFO typeid(detail::null_type).name() +#else #define LUABIND_TYPE_INFO const std::type_info* #define LUABIND_TYPEID(t) &typeid(t) #define LUABIND_TYPE_INFO_EQUAL(i1, i2) *i1 == *i2 #define LUABIND_INVALID_TYPE_INFO &typeid(detail::null_type) +#endif #include <typeinfo> #endif To turn on the new behavior just define LUABIND_TYPE_INFO_STRING. -- View this message in context: http://www.nabble.com/Binding-splitted-between-libraries-%28DLLs%29-tp24534417p24536238.html Sent from the Lua C++ Bind mailing list archive at Nabble.com. |