On Mon, Jul 5, 2010 at 6:57 AM, toki doki <[email protected]> wrote: > OK, I have merged the content of the Wrapping_C++ wiki into the user > guide Wrapping_C++. I did only minimal changes to the content of the > wiki. Therefore, the style could do with some improving, but at least > all the infos should be included.
Thanks for jumping in and doing this. The old documentation was in quite a sorry state, in part because no one wanted to clean up the old way of doing things (as it was "soon" to be supplanted) and then when the new stuff finally got merged, the documentation wasn't updated. > I slightly changed the structure, so that there is now only 4 main chapters: > - Overview > - A simple Tutorial (covering the basics of wrapping a C++ class) > - Advanced C++ features (covering everything that was not discussed in > the tutorial) > - Caveats and limitations ( extern "C" functions, references, ...) > > Compared to the wiki version, I added the following: > - nested class declaration syntax > - operators in cython.operator (only dereference and preincrement; if > someone know more of them, please tell me) > - pre-declared pxds for the standard library > > Now, to do the "documentation switch", it should just be enough to: > -- update the user guide with the attached file > -- update the wiki files > > Do you want to do the switch now or wait for the cython0.13 release? > Of course, anybody, feel free to first check the new file. It can > certainly do with some revisions. I've pushed it to the docs repo, which will replace what's at docs.cython.org when we release. http://hg.cython.org/cython-docs/rev/b4f6d17816d7 We can probably change the wiki right now, making a <= 0.12 page with the old instructions and link to the new stuff, which will get replaced by a link to the docs once those go live. This is one of those things where, down the road, I would love automatic testing on. > ******* > I have also a couple of questions that would deserved to be answered in the > doc. > > 1- The original user guide recommend the following for initializing an > extension class wrapping the C++ class Rectangle: > def __cinit__(self, int x0, int y0, int x1, int y1): > self.thisptr = new_Rectangle(x0, y0, x1, y1) > Should we recommend "def __cinit__(self, int x0, int y0, int x1, int > y1) except +MemoryError" instead? Yes, great catch. > 2- Am I correct that it is not possible to use stack-allocated C++ > objects as Python extension class members? Yes, at least as it stands now. Python extension classes are themselves allocated on the heap, and so we'd need to handle that in some special way, and it just gets really messy. (The details of stack-allocated classes are thorny in C++ itself, and things just get worse when trying to reason with them from another language...) > 3- The whole C++ reference thing still seems to be a bit messy, It is, and probably still has bugs, but was essential for some stuff. > so I > did not discuss it much in the doc. I am curious about one small > detail, though. In the STL pxds, the push_back function for vector is, > for example, declared like this: > > void push_back(&T) > > Why not just "void push_back(T)" ? More precisely: is there any point > to tell python which arguments of a declared function are references?. > It seems the code that cython must generate is the same in any case... Hmm... good point. I don't think it matters there (code-generation wise, semantically it makes a difference, but one would get that reading the C++ docs). > 4- I think there is no support for templated functions. Am I right? Correct (for now). > That's all for now. Thanks again! - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
