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
Gwenaël Samain
cython
Commits
6d5d7ce2
Commit
6d5d7ce2
authored
Apr 14, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor refactoring to reduce code redundancy
parent
9127adce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
34 deletions
+17
-34
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+17
-34
No files found.
Cython/Compiler/Nodes.py
View file @
6d5d7ce2
...
...
@@ -1402,6 +1402,23 @@ class FuncDefNode(StatNode, BlockNode):
"Argument type '%s' is incomplete"
%
arg
.
type
)
return
env
.
declare_arg
(
arg
.
name
,
arg
.
type
,
arg
.
pos
)
def
generate_arg_type_test
(
self
,
arg
,
code
):
# Generate type test for one argument.
if
arg
.
type
.
typeobj_is_available
():
typeptr_cname
=
arg
.
type
.
typeptr_cname
arg_code
=
"((PyObject *)%s)"
%
arg
.
entry
.
cname
code
.
putln
(
'if (unlikely(!__Pyx_ArgTypeTest(%s, %s, %d, "%s", %s))) %s'
%
(
arg_code
,
typeptr_cname
,
arg
.
accept_none
,
arg
.
name
,
arg
.
type
.
is_builtin_type
,
code
.
error_goto
(
arg
.
pos
)))
else
:
error
(
arg
.
pos
,
"Cannot test type of extern C class "
"without type object name specification"
)
def
generate_wrapper_functions
(
self
,
code
):
pass
...
...
@@ -1651,23 +1668,6 @@ class CFuncDefNode(FuncDefNode):
if
arg
.
needs_type_test
:
self
.
generate_arg_type_test
(
arg
,
code
)
def
generate_arg_type_test
(
self
,
arg
,
code
):
# Generate type test for one argument.
if
arg
.
type
.
typeobj_is_available
():
typeptr_cname
=
arg
.
type
.
typeptr_cname
arg_code
=
"((PyObject *)%s)"
%
arg
.
cname
code
.
putln
(
'if (unlikely(!__Pyx_ArgTypeTest(%s, %s, %d, "%s", %s))) %s'
%
(
arg_code
,
typeptr_cname
,
arg
.
accept_none
,
arg
.
name
,
type
.
is_builtin_type
,
code
.
error_goto
(
arg
.
pos
)))
else
:
error
(
arg
.
pos
,
"Cannot test type of extern C class "
"without type object name specification"
)
def
error_value
(
self
):
if
self
.
return_type
.
is_pyobject
:
return
"0"
...
...
@@ -2654,23 +2654,6 @@ class DefNode(FuncDefNode):
if
arg
.
needs_type_test
:
self
.
generate_arg_type_test
(
arg
,
code
)
def
generate_arg_type_test
(
self
,
arg
,
code
):
# Generate type test for one argument.
if
arg
.
type
.
typeobj_is_available
():
typeptr_cname
=
arg
.
type
.
typeptr_cname
arg_code
=
"((PyObject *)%s)"
%
arg
.
entry
.
cname
code
.
putln
(
'if (unlikely(!__Pyx_ArgTypeTest(%s, %s, %d, "%s", %s))) %s'
%
(
arg_code
,
typeptr_cname
,
arg
.
accept_none
,
arg
.
name
,
arg
.
type
.
is_builtin_type
,
code
.
error_goto
(
arg
.
pos
)))
else
:
error
(
arg
.
pos
,
"Cannot test type of extern C class "
"without type object name specification"
)
def
error_value
(
self
):
return
self
.
entry
.
signature
.
error_value
...
...
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