On Apr 3, 2009, at 1:59 AM, Dag Sverre Seljebotn wrote:

> Robert Bradshaw wrote:
>>
>> Note that the allocate-on-the-stack is not specific to just stacks.
>> For example, it is possible to define a C++ class as a member of a
>> cdef class, and then its memory is allocated along with the object as
>> part of the struct. Currently, one then has to actually initialize
>> and destroy manually.
>
> Good point. That's actually fairly tricky to do if the class doesn't
> have a no-arg constructor.

I believe it can be done (IIRC constructors can take a chunk of  
memory to initialize rather than allocating it themselves). I'm no  
expert on this though.

> If you have this:
>
> class MyClass {
>     MyClass(int x) {...} // non-empty constructor
> };
>
> Then in order to use it in a struct (without going through a pointer)
> one would actually have to do this:
>
> struct foo {
>    MyClass myinstance;
> public:
>    foo() : myinstance(any expression in globals) {}
> // or: foo(x,y,z) : myinstance(any expression in x,y,z,globals) {}
> }
>
> Getting Cython output code like this is non-trivial, at least without
> directly copying the member-construction-syntax of C++.

Yes, and perhaps outside the scope of this project.

- Robert

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

Reply via email to