[Cython] Syntax to declare a c++ class?
Robert Bradshaw
robertwb at math.washington.edu
Wed May 6 22:12:26 CEST 2009
On May 6, 2009, at 12:48 PM, Dag Sverre Seljebotn wrote:
> Robert Bradshaw wrote:
>> Just trying to get a syntax, how about
>>
>> cdef extern from "header.h":
>> cdef cclass MyClass[TemplateParamers](BaseCPPClass):
>> int member
>> int method(int)
>>
>> The only concern I have is whether or not "cdef cclass" is to similar
>> to "cdef class" (probably not). Any other ideas?
>
> cdef cppclass?
I don't like this one, but I think just for aesthetic reasons. Nor
cpp_class.
> Yes, I think cclass is to similar to class.
>
> Anyway, when I proposed a Fortran syntax earlier you and Stefan made a
> good point about the language specification belonging in the "cdef
> extern"
> part, as, after all, the "header.h" file contains only C++ code.
Will the compiler need to know that header.h is C++ code? If not, I
see no reason to declare it.
> Also consider that C++ needs namespace specifications, for instance
>
> cdef extern ...:
> namespace std:
> cdef cppclass vector[T]: ...
>
> or
>
> cdef cclass std::vector[T]: ...
Yep. That too. I'm a fan of both declarations. (Or even rolling the
"namespace" into the cdef extern statement.)
- Robert
More information about the Cython-dev
mailing list