|
List Info
Thread: New to Py++
|
|
| New to Py++ |
  Canada |
2008-03-30 09:36:30 |
|
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
“;exposed221; to be usable. I’ve tried the Py++ GUI, but
the C++ code I get from it doesn̵7;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 message.
Thank you in advance
Rolf Schlup
***************************************************************************************************************************************************************************
#!/usr/bin/python
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 declarations
mb = module_builder.module_builder_t( files=[
'VSControl.hpp']
, gccxml_path=r"/usr/local/bin/gccxml"
, working_directory=r"/home/rolf/source/ws_stes/BER/cobusiness/test/VisualSystemTest/VSPython/"
,
include_paths=['/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSCore'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSCommBase'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSException'
,'/home/rolf/source/ws_stes/UNT/real/Types'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSCoordConverter'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSEnumAndTypes'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSDefFileReader'
,'/usr/include/python/'
,'/home/rolf/source/ws_stes/BER/real/'
,'/home/rolf/source/ws_stes/BER/real/Global'
,'/home/rolf/source/ws_stes/BER/reglobal'
,'/home/rolf/source/ws_stes/BER/cobusiness/'
,'/home/rolf/source/ws_stes/UNT/real/'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSCommManager'
,'/home/rolf/source/ws_stes/BER/cobusiness/VisualSystem/VSComm'
]
, define_symbols=[] )
# The following 2 lines do not have any effect
mb.build_code_creator('VSControl')
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:
continue
if not mem_fun.call_policies and (declarations.is_reference(mem_fun.return_type)
or declarations.is_pointer (mem_fun.return_type)
):
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?
mb.print_declarations()
#Give a name to the module. After this step you should not
modify/customize declarations.
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
{
public:
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 ();
protected:
void createPacketRefList
();
void
evalIncommingPackets (const
std::vector<VSBasePacket*>& a_packetList);
void
handleSystemResponse (const
VSSystemPacket& a_systemPacket);
void
handleCollisionResponse ();
void
handleTerrainResponse (const
VSTerrainResponsePacket& a_terrainPacket);
void
handleEffectResponse (const
VSEffectResponsePacket& a_effectResponsePacket);
VSCommManager& getCommManager ();
void
handleIsectorResponse (const
VSBasePacket& a_isectorPacket);
bool m_Initialized;
std::vector<const
VSBasePacket*> m_PacketRefList;
ShVal<VSCommManager> m_CommManager;
private:
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
#endif
|
| Re: New to Py++ |

|
2008-03-30 12:13:47 |
2008/3/30 Rolf Schlup <rschlup highspeedcrow.ca>:
> Hi all,
Good evening
> 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.
Py++ GUI was created to suite single goal: to show what code
generates
Py++, without customization. You can use it almost as-is in
small
projects or when you just start with Boost.Python.
> 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.
Well, you can expose forward declarated classes as opaque
type. I
think that Py++ doesn't support thi use case. Normally what
you want
is to expose that classes too.
In order to do this, you need to create header file, that
will include
all relevant files and than to path is to Py++
> 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.
I guess this errors relaed to forward declarations. Try to
pass single
header file, built as described above.
> But, then when I try to import it, I get
> unresolved reference errors.
I think this error is related to your environment. Use
"dependency
viewer" to verify that your dll can load others.
>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 need more specific error description. From my experience
it is
better to start from something small, just few classes. To
get to the
point you can import and use few simple exported classes and
than
start to add other classes and functions.
--
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|
|
[1-2]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|