1

I've got class A wrapped with method foo implemented using %extend:

class A { ... %extend { void foo() { self->foo_impl(); } }

Now I want to increase ref count to an A inside foo_impl, but I only got A* (as self).

Question: how can I write/wrap function foo, so that I have an access both to A* and underlying PyObject*?

Thank you

1
  • There can be more than one underlying PyObject pointing to the same C++ object. You can get a PyObject (example) but it won't be the PyObject. Commented Apr 2, 2012 at 13:40

1 Answer 1

1

I think it's not possible. If you need to increase the refcount, it's because you don't want the C++ object to be destroyed when it goes out of scope because there is a pointer to that object elsewhere. In that case, look at using the DISOWN typemap to ensure the target language doesn't think it "owns" the C++ object, so it won't get destroyed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.