From: Lisandro Dalcin Date: Wed, 15 Oct 2008 15:10:09 +0000 (-0300) Subject: pyrex backport, accept ctypedef public api declarations X-Git-Tag: 0.9.9.2.beta~38 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=94b89da9773aafa486d6c0725b1975d97c4de564;p=cython.git pyrex backport, accept ctypedef public api declarations --- diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 2a2a5ac7..8ef8277a 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1406,8 +1406,8 @@ def p_statement(s, ctx, first_statement = 0): if s.sy == 'ctypedef': if ctx.level not in ('module', 'module_pxd'): s.error("ctypedef statement not allowed here") - if ctx.api: - error(s.position(), "'api' not allowed with 'ctypedef'") + #if ctx.api: + # error(s.position(), "'api' not allowed with 'ctypedef'") return p_ctypedef_statement(s, ctx) elif s.sy == 'DEF': return p_DEF_statement(s) @@ -2166,7 +2166,10 @@ def p_ctypedef_statement(s, ctx): pos = s.position() s.next() visibility = p_visibility(s, ctx.visibility) + api = p_api(s) ctx = ctx(typedef_flag = 1, visibility = visibility) + if api: + ctx.api = 1 if s.sy == 'class': return p_c_class_definition(s, pos, ctx) elif s.sy == 'IDENT' and s.systring in ('struct', 'union', 'enum'): diff --git a/tests/compile/ctypedefpubapi.pyx b/tests/compile/ctypedefpubapi.pyx new file mode 100644 index 00000000..091dc3d8 --- /dev/null +++ b/tests/compile/ctypedefpubapi.pyx @@ -0,0 +1,10 @@ +ctypedef public api class Foo [type PyFoo_Type, object PyFooObject]: + pass + +cdef api: + ctypedef public class Bar [type PyBar_Type, object PyBarObject]: + pass + +cdef public api: + ctypedef class Baz [type PyBaz_Type, object PyBazObject]: + pass