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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
df1b2449
Commit
df1b2449
authored
Sep 29, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanups of 'check_size' implementation (#2627).
parent
a6990434
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
17 deletions
+18
-17
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-0
Cython/Compiler/Parsing.pxd
Cython/Compiler/Parsing.pxd
+1
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+5
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+7
-7
No files found.
Cython/Compiler/ModuleNode.py
View file @
df1b2449
...
...
@@ -3061,9 +3061,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# check_size
if
not
type
.
is_external
or
type
.
is_subclassed
:
if
type
.
check_size
!=
'min'
:
raise
AttributeError
(
"unexpected check_size value '%s' when "
"compiling %s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
cs
=
0
elif
type
.
check_size
==
'min'
:
cs
=
1
...
...
@@ -3072,8 +3069,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
elif
type
.
check_size
==
False
:
cs
=
2
else
:
raise
AttributeError
(
"invalid value for check_size '%s' when compiling "
"%s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
raise
RuntimeError
(
"invalid value for check_size '%s' when compiling %s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
code
.
putln
(
'%d);'
%
cs
)
code
.
putln
(
' if (!%s) %s'
%
(
type
.
typeptr_cname
,
error_code
))
...
...
Cython/Compiler/Nodes.py
View file @
df1b2449
...
...
@@ -4617,6 +4617,7 @@ class PyClassDefNode(ClassDefNode):
self
.
bases
.
free_temps
(
code
)
code
.
pyclass_stack
.
pop
()
class
CClassDefNode
(
ClassDefNode
):
# An extension type definition.
#
...
...
Cython/Compiler/Parsing.pxd
View file @
df1b2449
...
...
@@ -188,7 +188,7 @@ cdef p_varargslist(PyrexScanner s, terminator=*, bint annotated = *)
cdef
p_py_arg_decl
(
PyrexScanner
s
,
bint
annotated
=
*
)
cdef
p_class_statement
(
PyrexScanner
s
,
decorators
)
cdef
p_c_class_definition
(
PyrexScanner
s
,
pos
,
ctx
)
cdef
p_c_class_options
(
PyrexScanner
s
)
cdef
tuple
p_c_class_options
(
PyrexScanner
s
)
cdef
p_property_decl
(
PyrexScanner
s
)
cdef
p_doc_string
(
PyrexScanner
s
)
cdef
p_ignorable_statement
(
PyrexScanner
s
)
...
...
Cython/Compiler/Parsing.py
View file @
df1b2449
...
...
@@ -3471,7 +3471,7 @@ def p_c_class_definition(s, pos, ctx):
objstruct_name
=
None
typeobj_name
=
None
bases
=
None
check_size
=
'min'
check_size
=
None
if
s
.
sy
==
'('
:
positional_args
,
keyword_args
=
p_call_parse_args
(
s
,
allow_genexp
=
False
)
if
keyword_args
:
...
...
@@ -3512,6 +3512,8 @@ def p_c_class_definition(s, pos, ctx):
error
(
pos
,
"Type object name specification required for 'api' C class"
)
else
:
error
(
pos
,
"Invalid class visibility '%s'"
%
ctx
.
visibility
)
if
check_size
is
None
:
check_size
=
'min'
# TODO: move into 'CClassDefNode'
return
Nodes
.
CClassDefNode
(
pos
,
visibility
=
ctx
.
visibility
,
typedef_flag
=
ctx
.
typedef_flag
,
...
...
@@ -3527,10 +3529,11 @@ def p_c_class_definition(s, pos, ctx):
doc
=
doc
,
body
=
body
)
def
p_c_class_options
(
s
):
objstruct_name
=
None
typeobj_name
=
None
check_size
=
'min'
check_size
=
None
s
.
expect
(
'['
)
while
1
:
if
s
.
sy
!=
'IDENT'
:
...
...
Cython/Compiler/PyrexTypes.py
View file @
df1b2449
...
...
@@ -1346,14 +1346,14 @@ class PyExtensionType(PyObjectType):
# early_init boolean Whether to initialize early (as opposed to during module execution).
# defered_declarations [thunk] Used to declare class hierarchies in order
# check_size 'min' or boolean What to do if tp_basicsize does not match
is_extension_type
=
1
has_attributes
=
1
early_init
=
1
objtypedef_cname
=
None
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
,
is_external
=
0
,
check_size
=
'min'
):
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
,
is_external
=
0
,
check_size
=
'min'
):
self
.
name
=
name
self
.
scope
=
None
self
.
typedef_flag
=
typedef_flag
...
...
Cython/Compiler/Symtab.py
View file @
df1b2449
...
...
@@ -1479,11 +1479,11 @@ class ModuleScope(Scope):
if
entry
.
utility_code_definition
:
self
.
utility_code_list
.
append
(
entry
.
utility_code_definition
)
def
declare_c_class
(
self
,
name
,
pos
,
defining
=
0
,
implementing
=
0
,
module_name
=
None
,
base_type
=
None
,
objstruct_cname
=
None
,
typeobj_cname
=
None
,
typeptr_cname
=
None
,
visibility
=
'private'
,
typedef_flag
=
0
,
api
=
0
,
check_size
=
'min'
,
buffer_defaults
=
None
,
shadow
=
0
):
def
declare_c_class
(
self
,
name
,
pos
,
defining
=
0
,
implementing
=
0
,
module_name
=
None
,
base_type
=
None
,
objstruct_cname
=
None
,
typeobj_cname
=
None
,
typeptr_cname
=
None
,
visibility
=
'private'
,
typedef_flag
=
0
,
api
=
0
,
check_size
=
'min'
,
buffer_defaults
=
None
,
shadow
=
0
):
# 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.
...
...
@@ -1515,8 +1515,8 @@ class ModuleScope(Scope):
# Make a new entry if needed
#
if
not
entry
or
shadow
:
type
=
PyrexTypes
.
PyExtensionType
(
name
,
typedef_flag
,
base_type
,
visibility
==
'extern'
,
check_size
=
check_size
)
type
=
PyrexTypes
.
PyExtensionType
(
name
,
typedef_flag
,
base_type
,
visibility
==
'extern'
,
check_size
=
check_size
)
type
.
pos
=
pos
type
.
buffer_defaults
=
buffer_defaults
if
objtypedef_cname
is
not
None
:
...
...
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