On Apr 29, 2008, at 2:05 PM, Marco Zanger wrote: > Hi, i've been trying to develop a Cython interface for a C++ graph > cut implementation. > > I have one class named GCOptimization and a child class named > GCoptimizationGeneralGraph and except from the constructor all the > others methods belong to GCOptimization. Reading this thread > (http://wiki.cython.org/WrappingCPlusPlus) I found that I might > have problems calling those methods, actually i'm having > "segmentation fault" problems and I don't know if it is because i'm > calling a method from a parent class or something else. > > for example, this is the class I defined (setDataCost method > belongs to GCOptimization not to GCoptimizationGeneralGraph) > > ctypedef struct c_GCoptimizationGeneralGraph > "GCoptimizationGeneralGraph": > void setDataCost(double *DataCost) > > c_GCoptimizationGeneralGraph *new_GCoptimizationGeneralGraph > "new GCoptimizationGeneralGraph" (int num_pixels,int num_labels) > void del_newGCoptimizationGeneralGraph > "delete" (c_GCoptimizationGeneralGraph *optimization) > > cdef class GCoptimizationGeneralGraph: > cdef c_GCoptimizationGeneralGraph *optimization > def __new__(self, num_pixels, num_labels): > self.optimization = new_GCoptimizationGeneralGraph > (num_pixels, num_labels) > def __dealloc__(self): > del_newGCoptimizationGeneralGraph(self.optimization) > def setDataCost(self, dataCost): > cdef double *temp = <double *>dataCost.data > self.optimization.setDataCost(temp) > > The question would be, could I have a problem with this? And in > case I do, how could I define the the parent/child relation in cython
Cython doesn't have any notion of the parent/child relationship of C+ + classes. I'm not sure why you're getting a segfault with this (I don't see anything obvious), but I would try running it under gdb to see where it's going wrong. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
