On Mon, Mar 22, 2010 at 7:44 PM, Ondrej Certik <[email protected]> wrote:
> Hi,
>
> today I fixed hopefully the remaining bugs in Python <-> C++ interface:
>
> * Use the Python() C++ class as the only interface to Python
> * properly deallocated all memory when the Python() class is deleted
> * fixed numerous segfaults related to that
> * figured out how to pass your own (derived) C++ class to Python and
> get its virtual methods called properly from Python
> * figured out how to write the PY_NEW() function in Cython only,
> without the need of the stdcython.h/c files (that we currently have in
> hermes2d)
> * wrote test cases to all of the above (that could also serve as
> examples of usage, both in Python and in C++)

I forgot to add, that the namespace is local to the Python() instance,
so the following works (see the tests):

void test_basic4()
{
    Python *p1 = new Python();
    Python *p2 = new Python();
    p1->push("i", c2py_int(5));
    p2->push("i", c2py_int(6));
    p1->exec("i = i*2");
    p2->exec("i = i*2");
    int i1 = py2c_int(p1->pull("i"));
    int i2 = py2c_int(p2->pull("i"));
    _assert(i1 == 10);
    _assert(i2 == 12);
    delete p1;
    delete p2;
}


Ondrej
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to