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
0817b5c8
Commit
0817b5c8
authored
Aug 05, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-instate 908 with working type names as argument names.
parent
bbe9f1cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+10
-3
tests/compile/cargdef.pyx
tests/compile/cargdef.pyx
+8
-1
No files found.
Cython/Compiler/Nodes.py
View file @
0817b5c8
...
@@ -362,8 +362,12 @@ class CNameDeclaratorNode(CDeclaratorNode):
...
@@ -362,8 +362,12 @@ class CNameDeclaratorNode(CDeclaratorNode):
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
if
nonempty
and
self
.
name
==
''
:
if
nonempty
and
self
.
name
==
''
:
# Must have mistaken the name for the type.
# May have mistaken the name for the type.
self
.
name
=
base_type
.
name
if
base_type
.
is_ptr
or
base_type
.
is_array
or
base_type
.
is_buffer
:
error
(
self
.
pos
,
"Missing argument name"
)
elif
base_type
.
is_void
:
error
(
self
.
pos
,
"Use spam() rather than spam(void) to declare a function with no arguments."
)
self
.
name
=
base_type
.
declaration_code
(
""
,
for_display
=
1
,
pyrex
=
1
)
base_type
=
py_object_type
base_type
=
py_object_type
self
.
type
=
base_type
self
.
type
=
base_type
return
self
,
base_type
return
self
,
base_type
...
@@ -422,6 +426,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
...
@@ -422,6 +426,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
optional_arg_count
=
0
optional_arg_count
=
0
def
analyse
(
self
,
return_type
,
env
,
nonempty
=
0
):
def
analyse
(
self
,
return_type
,
env
,
nonempty
=
0
):
if
nonempty
:
nonempty
-=
1
func_type_args
=
[]
func_type_args
=
[]
for
arg_node
in
self
.
args
:
for
arg_node
in
self
.
args
:
name_declarator
,
type
=
arg_node
.
analyse
(
env
,
nonempty
=
nonempty
)
name_declarator
,
type
=
arg_node
.
analyse
(
env
,
nonempty
=
nonempty
)
...
@@ -1050,7 +1056,8 @@ class CFuncDefNode(FuncDefNode):
...
@@ -1050,7 +1056,8 @@ class CFuncDefNode(FuncDefNode):
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
base_type
=
self
.
base_type
.
analyse
(
env
)
base_type
=
self
.
base_type
.
analyse
(
env
)
name_declarator
,
type
=
self
.
declarator
.
analyse
(
base_type
,
env
,
self
.
body
is
not
None
)
# The 2 here is because we need both function and argument names.
name_declarator
,
type
=
self
.
declarator
.
analyse
(
base_type
,
env
,
nonempty
=
2
*
(
self
.
body
is
not
None
))
if
not
type
.
is_cfunction
:
if
not
type
.
is_cfunction
:
error
(
self
.
pos
,
error
(
self
.
pos
,
"Suite attached to non-function declaration"
)
"Suite attached to non-function declaration"
)
...
...
tests/compile/cargdef.pyx
View file @
0817b5c8
def
f
(
obj
,
int
i
,
float
f
,
char
*
s1
,
char
s2
[]):
def
f
(
obj
,
int
i
,
float
f
,
char
*
s1
,
char
s2
[]):
pass
pass
cdef
g
(
obj
,
int
i
,
float
f
,
char
*
s1
,
char
s2
[]):
pass
cdef
do_g
(
object
(
*
func
)(
object
,
int
,
float
,
char
*
,
char
*
)):
return
func
(
1
,
2
,
3.14159
,
"a"
,
"b"
)
do_g
(
&
g
)
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