Perhaps I'm not being clear enough... perhaps and example will help.

Put this lines in a 'foo.pyx'  file anc cythonize it

# ---------------
cdef public class Foo [object PyFoo, type PyFoo_Type]:
    pass

cdef api void bar():
    pass
# --------------------

Then you will see that an 'foo_api.h' header is generated. Look at it
at the very begining, and you will see


static PyTypeObject *__pyx_ptype_3foo_Foo;
#define PyFoo_Type (*__pyx_ptype_3foo_Foo)

static void (*bar)(void);


Then, in the API header, Cython declares the type object with a
mangled C name, and then a #define.

Then, why isn't the same approach used for the C name 'bar' for the
function pointer? Does this make sense in order to 'protect' the
Cython-generated definition to interact badly with stuff that could be
got #include'd before the point "xxxx_api.h" is #include'd ??





On 6/10/08, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
>  Lisandro Dalcin wrote:
>  > cdef api void activate(Vehicle *v):
>  >    .....
>  >
>  > and then in the generated 'delorean_api.h' we have
>  >
>  > static void (*activate)(struct Vehicle *);
>  >
>  > Then the question is: Why the C name of the function pointer
>  > 'activate' is not mangled, using something like this (as it is
>  > similarly done for C type objects):
>  >
>  > static void (*__pyx_cfun_8delorean_activate)(struct Vehicle *);
>  > #define activate __pyx_cfun_8delorean_activate
>
>
> That's not the case for types at all. If you say
>
>     cdef public class _Element [ type LxmlElementType, object LxmlElement ]:
>
>  then the names appear in the C file unchanged.
>
>
>  Stefan
>  _______________________________________________
>  Cython-dev mailing list
>  [email protected]
>  http://codespeak.net/mailman/listinfo/cython-dev
>


-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to