From 94b89da9773aafa486d6c0725b1975d97c4de564 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Wed, 15 Oct 2008 12:10:09 -0300 Subject: [PATCH] pyrex backport, accept ctypedef public api declarations --- Cython/Compiler/Parsing.py | 7 +++++-- tests/compile/ctypedefpubapi.pyx | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/compile/ctypedefpubapi.pyx 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 -- 2.26.2