Re: Binding splitted between libraries (DLLs)

spam7000 <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
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.


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.