From: David Abrahams (abrahams_at_[hidden])
Date: 2000-10-16 10:58:57
Normally, people want to write the "business logic" of their applications in
Python and save C++ for the speed-critical components. If you can afford to
do what you're asking about, you might consider writing your whole
application in Python and dispensing with C++ altogether. That said...
It isn't well-documented yet, but py_cpp can be used for this purpose. You
can use the py::Callback template to call methods on the objects you get
from Python, e.g. something like this should work:
// caveat: UNTESTED!
const int strength = 10;
const char* manufacturer = "Vordon Empire";
module.get(), "Blaster", strength, manufacturer));
int old_strength = py::Callback<int>::call_method(a_blaster.get(),
py::Callback<void>::call_method(a_blaster.get(), "set_strength", 5);
I think that CXX (http://cxx.sourceforge.net) may be better at this job than
py_cpp, though I'm not at all sure.
----- Original Message -----
From: "Ted Milker" <tmilker_at_[hidden]>
> I've been following the C++/python sig mailing list and saw your
> posts about py_cpp. Reading the webpage, it exposes the C++
> classes you write to python, but can you recommend something for
> doing the opposite? I'd like to write a lot of the high level
> objects(NPC AI, items/weapons/etc) in Python and allow C++ to use
> those objects. That way I don't have to recompile the binary to
> modify the objects in the game world.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk