[C++-sig] Extending Python with not-basic-c++
Stefan Seefeld
seefeld at sympatico.ca
Thu Nov 30 16:12:09 CET 2006
David Sveningsson wrote:
> Hi, I have a working C++ game. To make it easier to
> extend/control/whatever some kind of scripting support is required. I
> know Python isn't really a scripting language but it seems like the best
> choice. I should also note that my knowledge of python is very limited.
>
> I heard that embedding python isn't a good way so I'm about to extend
Why not ?
> python with my functionality. At first I would like to just replace my
> game loop from C++ to python. It's basically a class with a method that
> keeps looping until the game is finished.
>
> But this class and all other classes inherits from a common 'object'
> class. And all memory is allocated through a memory manager. Also, the
> object class is dependent on a couple of other classes. And circular
> dependencies is not uncommon. It is not possible to loose this coupling.
OK. So you want to keep control over your C++ object's memory allocation
in C++. That probably means that all the object creation, as far as the
python bindings are concerned, should happen through a factory, with
objects marked 'non-copyable', and return-value-policies generally
'return-existing-object' or somesuch.
> When compiling a class module for python it says undefined symbol 'a
> class method here'. So I include that class-objectfile when I compile
> the module. Eventfully it works but I cant do like this.
You really ought to provide some more detail here if you expect anybody
to be able to help. Some code snippets, together with the actual error
message from your compiler.
Regards,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list