Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
5ce9ee47
Commit
5ce9ee47
authored
Sep 10, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ticket #355 - ctypedef class ordering
parent
23e1262c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
9 deletions
+20
-9
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+3
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+12
-1
tests/compile/ctypedef_public_class_T355.pxd
tests/compile/ctypedef_public_class_T355.pxd
+1
-1
tests/compile/ctypedef_public_class_T355.pyx
tests/compile/ctypedef_public_class_T355.pyx
+1
-1
tests/errors/e_ctypedefforward.pyx
tests/errors/e_ctypedefforward.pyx
+0
-6
No files found.
Cython/Compiler/ModuleNode.py
View file @
5ce9ee47
...
...
@@ -811,6 +811,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"%s;"
%
attr
.
type
.
declaration_code
(
attr
.
cname
))
code
.
putln
(
footer
)
if
type
.
objtypedef_cname
is
not
None
:
# Only for exposing public typedef name.
code
.
putln
(
"typedef struct %s %s;"
%
(
type
.
objstruct_cname
,
type
.
objtypedef_cname
))
def
generate_global_declarations
(
self
,
env
,
code
,
definition
):
code
.
putln
(
""
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
5ce9ee47
...
...
@@ -368,6 +368,7 @@ class PyExtensionType(PyObjectType):
# base_type PyExtensionType or None
# module_name string or None Qualified name of defining module
# objstruct_cname string Name of PyObject struct
# objtypedef_cname string Name of PyObject struct typedef
# typeobj_cname string or None C code fragment referring to type object
# typeptr_cname string or None Name of pointer to external type object
# vtabslot_cname string Name of C method table member
...
...
@@ -378,6 +379,8 @@ class PyExtensionType(PyObjectType):
is_extension_type
=
1
has_attributes
=
1
objtypedef_cname
=
None
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
):
self
.
name
=
name
self
.
scope
=
None
...
...
Cython/Compiler/Symtab.py
View file @
5ce9ee47
...
...
@@ -1010,6 +1010,15 @@ class ModuleScope(Scope):
module_name = None, base_type = None, objstruct_cname = None,
typeobj_cname = None, visibility = 'private', typedef_flag = 0, api = 0,
buffer_defaults = None):
# If this is a non-extern typedef class, expose the typedef, but use
# the non-typedef struct internally to avoid needing forward
# declarations for anonymous structs.
if typedef_flag and visibility != 'extern':
objtypedef_cname = objstruct_cname
objstruct_cname = None
typedef_flag = 0
else:
objtypedef_cname = None
#
# Look for previous declaration as a type
#
...
...
@@ -1034,6 +1043,8 @@ class ModuleScope(Scope):
type = PyrexTypes.PyExtensionType(name, typedef_flag, base_type)
type.pos = pos
type.buffer_defaults = buffer_defaults
if objtypedef_cname is not None:
type.objtypedef_cname = objtypedef_cname
if visibility == 'extern':
type.module_name = module_name
else:
...
...
tests/compile/ctypedef_public_class_T355.pxd
View file @
5ce9ee47
tests/compile/ctypedef_public_class_T355.pyx
View file @
5ce9ee47
tests/errors/e_ctypedefforward.pyx
View file @
5ce9ee47
ctypedef
struct
Spam
ctypedef
class
Eggs
cdef
extern
from
*
:
ctypedef
struct
Ham
...
...
@@ -7,12 +6,7 @@ cdef extern from *:
ctypedef
struct
Spam
:
int
i
ctypedef
class
Eggs
:
pass
ctypedef
struct
Spam
ctypedef
class
Eggs
_ERRORS
=
u"""
1:0: Forward-referenced type must use 'cdef', not 'ctypedef'
2:0: Forward-referenced type must use 'cdef', not 'ctypedef'
"""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment