[C++-sig] New to Py++

Rolf Schlup rschlup at highspeedcrow.ca
Sun Mar 30 16:36:30 CEST 2008

Hi all,

  I'm new to Py++ and I need to create bindings for a Visual Simulation
control library for the company I work for.  The library consists of over
200 classes of which 50 or need to be "exposed" to be usable.  I've tried
the Py++ GUI, but the C++ code I get from it doesn't compile.  There is one
main interface class - VSControl -  that has methods for returning
references to members ( mostly of other classes ).  Some of the classes have
forward referencing of their dependencies which causes the C++ to completely
haywire and I'm thinking it has something to do with how Py++ generates the
wrapper code.  I'm also having a lot of issues with Call Policies. Mainly,
the ones that have with return of reference types are giving me warnings
when I generate the C++ code.  I've been using the followingcode, but the
resulting C++ code only compiles when I manually add the necessary header
files to the generated code.  But, then when I try to import it, I get
unresolved reference errors.  If I try to add all necessary files to the
builder lines, the warnings and compiler errors increase exponentially.
Again, any help or examples that can yield usable binding code will be
appreciated.  I've included the VSControl header file at the end of this


Thank you in advance


Rolf Schlup





import os

import sys

sys.path.append( '../../../..' )

from pyplusplus import module_builder

from pyplusplus.module_builder import call_policies

from pygccxml import declarations

from pygccxml.declarations import custom_matcher_t as c_matcher

from pygccxml.declarations import regex_matcher_t as re_matcher

#Creating an instance of class that will help you to expose your


mb = module_builder.module_builder_t( files=[ 'VSControl.hpp']

                                      , gccxml_path=r"/usr/local/bin/gccxml"


















                                      , define_symbols=[] )

# The following 2 lines do not have any effect


mb.code_creator.add_include( "path.hpp" ) 


mem_funs = mb.calldefs()

mem_funs.create_with_signature = True

for mem_fun in mem_funs:

  if mem_fun.call_policies:


  if not mem_fun.call_policies and
(declarations.is_reference(mem_fun.return_type) or declarations.is_pointer


     mem_fun.call_policies =
call_policies.return_value_policy(call_policies.reference_existing_object )



#Well, don't you want to see what's going on?



#Give a name to the module. After this step you should not modify/customize

mb.build_code_creator( module_name='vscontrol' )


#I don't want absolute includes within code

mb.code_creator.user_defined_directories.append( os.path.abspath('.') )


#Write code to file.

mb.write_module( os.path.join( os.path.abspath('.'),'VSControl_Bindings.cpp'
) )





#ifndef VSControl_h

#define VSControl_h 1


#include "Global/REALGlobal.hpp"

#include "VisualSystem/VSCommBase/VSAllPacketDefinitions.hpp"


namespace N_VisualSystem {

  class VSBasePacket;

  class VSCommManager;

  class VSConverterBase;

  class VSMunitionMan;

  class VSIsectorMan;

  class VSCreatureMan;

  class VSSensorMan;

  class VSCelestial;

  class VSEntityMan;

  class VSObjectAllocater;

  class VSSystem;

  class VSEffectMan;

  class VSTerrainMan;

  class VSHudMan;

  class VSTextMan;

  class VSWeatherMan;

  class VSSightMan;


} // namespace N_VisualSystem


namespace N_VisualSystem {


  class VSControl 



        VSControl ();

        virtual ~VSControl();

        virtual bool init (const std::string& a_configFileName, const
std::string& a_interfaceName);

        VSWeatherMan& getWeatherMan ();

        VSCelestial& getCelestial () const;

        VSCreatureMan& getCreatureMan () const;

        VSEffectMan& getEffectMan ();

        VSEntityMan& getEntityMan () const;

        VSHudMan& getHudMan ();

        VSIsectorMan& getIsectorMan () const;

        VSMunitionMan& getMunitionMan ();

        VSSensorMan& getSensorMan ();

        VSSightMan& getSightMan () const;

        VSSystem& getSystem ();

        VSTerrainMan& getTerrainMan ();

        VSTextMan& getTextMan ();

        virtual bool isUpdateRequested ();

        void startUpdate ();

        void endUpdate ();

        bool getConnectionState () const;

        void preUpdate ();



        void createPacketRefList ();

        void evalIncommingPackets (const std::vector<VSBasePacket*>&

        void handleSystemResponse (const VSSystemPacket& a_systemPacket);

        void handleCollisionResponse ();

        void handleTerrainResponse (const VSTerrainResponsePacket&

        void handleEffectResponse (const VSEffectResponsePacket&

        VSCommManager& getCommManager ();

        void handleIsectorResponse (const VSBasePacket& a_isectorPacket);

        bool m_Initialized;

        std::vector<const VSBasePacket*> m_PacketRefList;

        ShVal<VSCommManager> m_CommManager;


        VSControl(const VSControl &right);

        VSControl & operator=(const VSControl &right);

        bool operator==(const VSControl &right) const;

        bool operator!=(const VSControl &right) const;

        void installDefaultCoordConverter ();


        ShVal<VSEntityMan> m_EntityManager;

        ShVal<VSTerrainMan> m_TerrainManager;

        ShVal<VSSystem> m_System;

        ShVal<VSSightMan> m_SightManager;

        ShVal<VSWeatherMan> m_WeatherManager;

        ShVal<VSTextMan> m_TextManager;

        ShVal<VSHudMan> m_HudManager;

        ShVal<VSEffectMan> m_EffectManager;

        ShVal<VSCelestial> m_Celestial;

        ShVal<VSSensorMan> m_SensorManager;

        ShVal<VSCreatureMan> m_CreatureManager;

        ShVal<VSIsectorMan> m_IsectorManager;

        ShVal<VSMunitionMan> m_MunitionManager;

        VSConverterBase* m_DefaultConverter;





} // namespace N_VisualSystem




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080330/bffacd3d/attachment.htm>

More information about the Cplusplus-sig mailing list