On Apr 26, 2009, at 12:21 PM, Ondrej Certik wrote: > > On Sun, Apr 26, 2009 at 2:27 AM, Robert Bradshaw > <rober...@math.washington.edu> wrote: >> >> On Apr 26, 2009, at 2:08 AM, Ondrej Certik wrote: >>> So when I am exposing a new class, i it's quite a lot of typing, >>> especially the name of the C++ class has to be copied over and over >>> again (e.g. in the definition of the new constructor, etc). Compared >>> to swig, it was much easier to do it in swig, where you basically >>> just >>> copy the C++ header file and swig does the rest. That said, the >>> Cython >>> way is of course much cleaner in the end, once I have it written >>> already. >> >> Yes, one of the differences between Cython and swig is that swing >> provides automated wrappers, whereas Cython lets you use the library >> directly, not just wrap it. Of course wrappers can still be done, >> it's more manual work (sometimes this is good as it allows a more >> "pythonic" interface to the underlying library) There was someone who >> prototyped a tool to do auto-generate classes (I believe he called it >> ccython) which read in C++ files and generated .pyx files. Not sure >> how far it went. > > > I would like to stick to Cython and I don't want any magic behind the > scene, e.g. I like the Cython way. But still I believe it could be > made simpler. > > Currently one basically uses a C like syntax to handle C++ classes. > And of course one can do OO programming in C, but it's just a lot of > typing. That's why I actually prefer C++ for OO stuff, becuase I don't > have to type that much --- the syntax for defining a class+methods is > way less verbose than doing a C struct and then constructor, > destructor, etc. as C functions. > > So my idea was that maybe Cython .pxd definition could be similarly > less verbose. As an example, I could imagine going from: > > cdef struct c_WeakForm "WeakForm": > void add_biform(int i, int j, ...) > void add_biform_surf(int i, int j, ...) > void add_liform(int i, ...) > void add_liform_data(int i, void *data) > void add_liform_surf(int i, ...) > c_WeakForm *new_WeakForm "new WeakForm" (int neq)
Yes, it will certainly get cleaner than this... > to something like: > > cdef class WeakForm: > WeakForm(int neq) > void add_biform(int i, int j, ...) > void add_biform_surf(int i, int j, ...) > void add_liform(int i, ...) > void add_liform_data(int i, void *data) > void add_liform_surf(int i, ...) Are you trying to simultaneously declare a C++ and a Cython class here? - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---