Yes, but it seems I'm unable  to see the wood for the trees.

The concrete situation:
Im developing a Interface that supposedly is going to enable AIs being written in Python for a C/C++ environment. What I get is a pointer to a Callback Instance I have to deliver to the AI dev (Python side). The Instance enables the AI dev to ask question about the Applications state so the AI reacts accordingly. Now I have a boost::module wrapper for the Class Im getting a reference of and successfully built a callback so the embedded Python is able to fetch the Callback Instance coming from the App. But I run into...

Sandbox:

// The Callback coming from the Application of which I am not allowed to taint the Source Tree
struct EngineCallback
{
    void setInt(int number) { this->number = number; }
    void setLoop(bool loop) { this->loop = loop; }
    int getInt() { return this->number; }
    bool getLoop() { return this->loop; }

    int number;
    bool loop;
};

EngineCallback* test = new EngineCallback;

// Entrypoint for Python to come ant fetch the Application Callback
shared_ptr<EngineCallback> PyCallback( EngineCallback* &test ) { return shared_ptr<EngineCallback>(test); } // The Problem? ...how to convert?

// The Wrapper for all this
BOOST_PYTHON_MODULE(EngineCallback)
{
    class_<EngineCallback, shared_ptr<EngineCallback>, boost::noncopyable>("EngineCallback", no_init)
        .def("setInt", &EngineCallback::setInt)
        .def("setLoop", &EngineCallback::setLoop)
        .def("getInt", &EngineCallback::getInt)
        .def("getLoop", &EngineCallback::getLoop)
    ;

    def("PyCallback", &PyCallback);
}

# test.py
from EngineCallback import PyCallback
from EngineCallback import EngineCallback

test = PyCallback()
dir(test)

>>>>>> ends in:
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    test = PyCallback()
Boost.Python.ArgumentError: Python argument types in
    EngineCallback.PyCallback()
did not match C++ signature:
    PyCallback(EngineCallback* {lvalue})

Conversions in PyCallback missing?, how/with what do I accomplish them?

I think Im having trouble with C/C++ more in general than anything else, but I would appreciate if you could just point to the things I should look at to understand and come up with a solution.

Thanks in advance,
lwk


On 25 May 2010 15:40, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG


Leonhard Weber wrote:
I'm in the same bind  this topic describes:
http://lists.boost.org/boost-users/2009/02/44749.php
Unfortunately the subject didn't tell about the resolution or approach he
took to succeed. Can anyone help me?

Basically: I want to expose a C++ Instance to Python at runtime. I have a
pointer to the Instance and need to expose that instance to Python.
 

Have you tried the Boost.Python documentation?
http://www.boost.org/libs/python/

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org