[C++-sig] [Py++] RuntimeError: `Py++` is going to write different content to the same file

Roman Yakovenko roman.yakovenko at gmail.com
Fri Aug 7 20:05:16 CEST 2009


On Fri, Aug 7, 2009 at 12:27 PM, Razvan Yorik<razvan_76 at ymail.com> wrote:
>
> Hello,
> I have a problem wrapping the following header file using Py++. The class "Derived<T>" defines a local typedef "Helper" which has different meanings for each template parameter "T".
>
> Wrapped header:
> ---------- test.h ----------
> #ifndef TEST_H
> #define TEST_H
>
> template<class T> class Base{
> public:
> };
>
> template<class T> class Derived: public Base<T>{
> public:
>    typedef Base<T> Helper;
> };
>
> This leads to the error (full output log at the end of this email):
>
> RuntimeError: `Py++` is going to write different content to the same file(split/Helper.pypp.hpp).
> The following is a short list of possible explanations for this behaviour:
> * `Py++` bug, in this case, please report it
> * module_builder_t contains two or more classes with the same alias
> * module_builder_t contains two or more classes with the same wrapper alias
> Please carefully review `Py++` warning messages. It should contain an additional information.
>
> I tried to rename or exclude the "Helper" class from the wrapper, but the problem is, that it is not even in mb.classes():
>

This is because "Helper" is an alias. "Base<int>" is illegal Python
identifier, so Py++ has to build a legal one for you class. In this
case it found that you call your class "Helper" and choose it as the
alias

>>print [c.name for c in mb.classes()]
> ['Derived<float>', 'Derived<int>', 'Base<float>', 'Base<int>']

for cls in mb.classes():
    print "full name: %s, alias: %s" % ( cls.decl_string, cls.alias )

> Is there a possibility to
> - rename the different Helpers to "HelperInt" and "HelperFloat" in the code generator

for cls in mb.classes():
    cls.alias = 'helper_' + cls.split( '<' )[1].split('>' )[0]

or
> - apply minor changes to the header only for GCCXML, but without changing the classes (they are simplified from a bigger project!)
> - or to exclude the Helper class?

I suggest you to take a look on Py++ example. You will find the very useful.


HTH

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/


More information about the Cplusplus-sig mailing list