I've been looking at pybindgen and have a simple question -- why do
the container wrappers not implement more of the python container
interface? For instance, you can expose the std::vector like so:
vecint = mod.add_container("std::vector", "int",
"vector", custom_name="vector_o
Hi Taner,
Thanks for the suggestion! I actually was trying the same solution,
except I wasn't sure how to handle the iterators. I'll try it out as
you do in your example -- are you able to iterate over the vector in
python the usual way? As in "for x in vec:"?
Two curious things I note
Hi Gustavo,
Hmm. OK, if I read that page correctly what I would need in order to
emulate a python sequence, mapping, or number is the ability to
register PySequenceMethods, PyMappingMethods, or PyNumberMethods
then? Maybe I'll dig around in the code and see if this is difficult
to add.
I'm looking at wrapping a C++ singleton with pybindgen, and it seems
that if I expose the method for getting the instance to python the
generated code wants to call a copy constructor, which seems wrong to
me. If for instance I define a class "A" as a singleton:
class A {
public:
static
Ah, I see! That does the trick! Thank you very much. I was clearly
confused about what "caller_owns_return" meant -- I had it backwards.
Mike.
On Jun 22, 2009, at 5:11 PM, Gustavo Carneiro wrote:
2009/6/22 J. Michael Owen
I'm looking at wrapping a C++ singleton with py
Hi again,
I've run across another issue confusing me as I try to use pybindgen,
in this case it's the treatment of reference parameters in virtual
methods where you're allowing the class to be subclassed from python.
It looks like the helper class that is generated is making copies of
pa
I can see what you're worried about here, but as a practical matter it
is very useful to be able to pass stuff by reference, and copying it
under the hood will break code. For instance, if the virtual
functions modify the state of the parameters passed by reference it
will just not functio
That sounds great to me!
On Jun 24, 2009, at 5:03 PM, Gustavo Carneiro wrote:
I can't really fault your logic.
I just thought of something that makes some sense. If the wrapper
did something like:
_wrap_my_virtual_method (A &a)
{
PyA *py_A;
py_A = PyObject_New(PyA, &PyA_Type);
Hi Gustavo,
Hmm. I tried this example, but the generated code seems to be still
trying to generate a copy. Here's the example source I'm trying expose:
#include
class A {
public:
A(const int val): mVal(val) {}
private:
int mVal;
A();
A(const A& rhs);
A& operator=(const A& rhs);
I pulled down your bazaar branch and merged it with my own changes (I
need to use the container methods, inplace numeric operators, and
numeric operators with built in python types, so I have to keep using
my changes for now), and now reference parameters are working just
fine. Great!
S
Hello Gustavo,
I have some further evolved changes for the sequence methods that you
may want to use over my previous version. This is more general, and
involves less code as I realized I could register the sequence methods
to just call the wrapped methods pybindgen is already providing.
11 matches
Mail list logo