[C++-sig] Avoiding duplicate registration of Py++ generatedarray code?
Haridev, Meghana
mharidev at qualcomm.com
Mon Jan 22 20:47:43 CET 2007
Hi Roman,
I agree that your suggestions would help in getting rid of the warnings
for duplicate registration, but here is what I am really concerned
about:
When we do this:
>> import Boost_Lib1
>> import Boost_Lib2
>> RuntimeWarning: to-Python converter for
pyplusplus::containers::static_sized::array_1_t<unsigned char, 128>
already registered; second conversion method ignored.
The to-Python converter that will be used for
pyplusplus::containers::static_sized::array_1_t<unsigned char, 128> by
Class C (of library Boost.Lib2.so) is actually registered(by Class A) in
ANOTHER library (Boost_Lib1.so) .
1) Are there any problems that could arise from using a to-Python
converter that resides in ANOTHER shared library? Ideally, I would like
to use a to-Python converter that is registered within the SAME shared
library.
2) Regarding using a string as another template argument, it is possible
to do so. Here's some example code:
extern char const s[] = "hello";
template <char const* name>
class MyClass {
...
};
MyClass<s> x;
Here, the global character array s is initialized by "hello" so that s
is an object with external linkage.
This way using another template argument for the array classes (such as
a unique string: template< class TItemType, long unsigned int size, char
const* name >) we can ensure that to-Python converters for each array
will be registered within the SAME shared library. What do you think?
Thanks,
-Meghana.
-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of Roman Yakovenko
Sent: Friday, January 19, 2007 4:03 AM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Avoiding duplicate registration of Py++
generatedarray code?
On 1/19/07, Haridev, Meghana <mharidev at qualcomm.com> wrote:
> But when I have an array (dataC) of the SAME TYPE and SIZE but wrapped
in a
> different module, I get this warning for duplicate registration when I
> import the 2nd module:
>
>
> 1) How can I avoid duplicate registration across modules?
There are few possible solutions. The best one I can think is ...
1. Take a look on boost/libs/python/src/object/class.cpp file. You
should be able to find query_class function. You can make this
function public or to duplicate the
code. After this you have to go and modify
http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/pyplu
splus/code_repository/array_1.py?view=markup
file. Add small check whether the class already registered or not.
It could be nice if you could submit the patch to Py++.
> 2) Is there any known way by which I can get rid of this warning?
Just comment it out within Boost.Python sources.
> 3) I know that this warning can be gotten rid of by adding another
template
> parameter (like a unique string across modules)
String could not be template argument.
> - If I plan on incorporating
> this, is there a lot of effort required? Pointers to which files that
might
> need to be modified would be much appreciated!
The patch to Py++ too :-)
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig
More information about the Cplusplus-sig
mailing list