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;
};

#ifdef __GCCXML__
void instantiate(){
  sizeof(Base<int>);
  sizeof(Base<float>);
  sizeof(Derived<int>);
  sizeof(Derived<float>);
}
#endif

#endif
---------- end of test.h ----------

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():

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

Is there a possibility to
- rename the different Helpers to "HelperInt" and "HelperFloat" in the code 
generator 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 hope someone can suggest a solution or a workaround.
Thank you
Razvan

Code generator:
---------- generate_code.py ----------
import os
from pyplusplus import module_builder
from pyplusplus.decl_wrappers import call_policies
from pygccxml.declarations.matchers import access_type_matcher_t
from pyplusplus import function_transformers as FT

files=['test.H']

mb = module_builder.module_builder_t(
        files=files,
        define_symbols=[],
        include_paths=[]
    )
mb.build_code_creator( module_name='pytest' )
mb.code_creator.user_defined_directories.append( os.path.abspath('.') )
mb.split_module("split")
mb.write_module( os.path.join( os.path.abspath('.'), 'generated.cpp' ) )
---------- end of generate_code.py ----------

---------- complete ouput ----------
$ python generate_code.py 
INFO Parsing source file "test.H" ... 
INFO gccxml cmd: /usr/local/bin/gccxml  -I"."   "test.H" 
-fxml="/tmp/tmpM2O_z-.xml"
INFO GCCXML version - 0.9( 1.128 )

WARNING: Base<float> [class]
> warning W1047: There are two or more classes that use same alias("Helper"). 
> Duplicated aliases causes few problems, but the main one is that some
> of the classes will not be exposed to Python.Other classes : Base<int> [class]

WARNING: Base<int> [class]
> warning W1047: There are two or more classes that use same alias("Helper"). 
> Duplicated aliases causes few problems, but the main one is that some
> of the classes will not be exposed to Python.Other classes : Base<float> 
> [class]
Traceback (most recent call last):
  File "generate_code.py", line 20, in <module>
    mb.split_module("split")
  File 
"/usr/lib/python2.5/site-packages/pyplusplus/module_builder/boost_python_builder.py",
 line 373, in split_module
    , encoding=self.encoding)
  File "/usr/lib/python2.5/site-packages/pyplusplus/file_writers/__init__.py", 
line 37, in write_multiple_files
    mfs.write()
  File 
"/usr/lib/python2.5/site-packages/pyplusplus/file_writers/multiple_files.py", 
line 406, in write
    self.split_classes()
  File 
"/usr/lib/python2.5/site-packages/pyplusplus/file_writers/multiple_files.py", 
line 307, in split_classes
    map( self.split_class, class_creators )
  File 
"/usr/lib/python2.5/site-packages/pyplusplus/file_writers/multiple_files.py", 
line 294, in split_class
    self.split_class_impl( class_creator )
  File 
"/usr/lib/python2.5/site-packages/pyplusplus/file_writers/multiple_files.py", 
line 268, in split_class_impl
    , self.create_function_code( function_name ) ) )
  File 
"/usr/lib/python2.5/site-packages/pyplusplus/file_writers/multiple_files.py", 
line 58, in write_file
    raise RuntimeError( os.linesep.join(msg) )
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.
---------- end of output----------


      
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to