Re: [pygccxml-development] Compilation problem
Brought to you by:
mbaas,
roman_yakovenko
From: Vincent F. <vin...@gm...> - 2008-09-18 12:41:52
|
Bad evaluation. I have a class NastranDatabase which inherits from GenericDatabase. When I call the constructor of the NastranDatabase, the only one constructor called is the GenericDatabase one... not both. I tried to make a very simple example with this two classes and it works perfectly fine. Here is the file database.cpp : #include "database.h" #include <iomanip> #include <iostream> using namespace std ; using namespace postLib; using namespace generic; database::database(void) { cout << "Constructeur de la Generic Database." << endl; } Here is the file nastranDatabase.cpp : #include "nastranDatabase.h" #include <iomanip> #include <iostream> using namespace std ; using namespace postLib; using namespace nastran; database::database(void) : generic::database() { cout << "Constructeur de la Nastran Database." << endl; } My code generator : import os import pyplusplus import common_utils from environment import settings from pyplusplus import code_creators from pyplusplus import module_builder from pyplusplus import messages from pygccxml import declarations from pyplusplus.module_builder import call_policies from pyplusplus import function_transformers as FT license = \ """ /* * My program license */ """ def export(): global license header_files = [os.path.join(settings.ferespost_path, "pyferespost.h")] # Create configuration for GCC-XML parser # Initialize module builder mb = module_builder.module_builder_t(header_files, gccxml_path=settings.gccxml_path, working_directory=settings.ferespost_path, include_paths=[settings.ferespost_path], define_symbols=[]) #Well, don't you want to see what is going on? # Please be quiet... I'll be grateful # mb.print_declarations() mb.classes().exclude() genericDatabase = mb.namespace('postLib').namespace('generic').class_('database') genericDatabase.include() nastranDatabase = mb.namespace('postLib').namespace('nastran').class_('database') nastranDatabase.include() genericDatabase.rename('Generic' + genericDatabase.name.capitalize()) nastranDatabase.rename('Nastran' + nastranDatabase.name.capitalize()) #Creating code creator. After this step you should not modify/customize declarations. mb.build_code_creator(settings.module_name) mb.code_creator.license = license mb.code_creator.user_defined_directories.append(settings.ferespost_path) mb.code_creator.precompiled_header = 'boost/python.hpp' #Writing code to multiple files, much easier to add missing call_policies. mb.split_module(settings.generated_files_dir) # Main generation fonction if __name__ == '__main__': export() print 'done' The test program and its output : import pyferespost print "Generic Database : " pyferespost.GenericDatabase() print "Nastran Database : " pyferespost.NastranDatabase() Generic Database : Constructeur de la Generic Database. Nastran Database : Constructeur de la Generic Database. Constructeur de la Nastran Database. So for now, all seems to be ok. If I do the same things in my whole application, when I instanciate a NastranDatabase, the only constructor called is the GenericDatabase one. Here is the corresponding generated code for the constructor definition : GenericDatabase : #include "boost/python.hpp" #include "pyferespost.h" #include "GenericDatabase.pypp.hpp" namespace bp = boost::python; struct dataBase_wrapper : postLib::generic::dataBase, bp::wrapper< postLib::generic::dataBase > { dataBase_wrapper( ) : postLib::generic::dataBase( ) , bp::wrapper< postLib::generic::dataBase >(){ // null constructor } // A LOT OF FUNCTION DEFINITIONS HERE }; void register_GenericDatabase_class(){ { //::postLib::generic::dataBase typedef bp::class_< dataBase_wrapper, boost::noncopyable > GenericDatabase_exposer_t; GenericDatabase_exposer_t GenericDatabase_exposer = GenericDatabase_exposer_t( "GenericDatabase", bp::init< >() ); bp::scope GenericDatabase_scope( GenericDatabase_exposer ); // A LOT OF FUNCTION DEFINITIONS HERE } NastranDatabase : #include "boost/python.hpp" #include "pyferespost.h" #include "NastranDatabase.pypp.hpp" namespace bp = boost::python; struct dataBase_wrapper : postLib::nastran::dataBase, bp::wrapper< postLib::nastran::dataBase > { dataBase_wrapper( ) : postLib::nastran::dataBase( ) , bp::wrapper< postLib::nastran::dataBase >(){ // null constructor } // A LOT OF FUNCTION DEFINITIONS HERE }; void register_NastranDatabase_class(){ bp::class_< dataBase_wrapper, bp::bases< postLib::generic::dataBase >, boost::noncopyable >( "NastranDatabase") .def(bp::init< >() ) // A LOT OF .def HERE } Is there a problem in my wrappers? Why is the NastranDatabase constructor never called (it should call both)? Any idea? Thanks in advance. |