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
Boxiang Sun
cython
Commits
b93bc723
Commit
b93bc723
authored
Mar 08, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change display of typedef types, use plain name instead of qualified name
parent
3594f918
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
21 deletions
+31
-21
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+8
-13
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-1
tests/errors/e_excvalfunctype.pyx
tests/errors/e_excvalfunctype.pyx
+2
-2
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+5
-5
tests/run/embedsignatures.pyx
tests/run/embedsignatures.pyx
+14
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
b93bc723
...
@@ -164,13 +164,13 @@ class PyrexType(BaseType):
...
@@ -164,13 +164,13 @@ class PyrexType(BaseType):
return
1
return
1
def
create_typedef_type
(
cname
,
base_typ
e
,
is_external
=
0
):
def
create_typedef_type
(
name
,
base_type
,
cnam
e
,
is_external
=
0
):
if
base_type
.
is_complex
:
if
base_type
.
is_complex
:
if
is_external
:
if
is_external
:
raise
ValueError
(
"Complex external typedefs not supported"
)
raise
ValueError
(
"Complex external typedefs not supported"
)
return
base_type
return
base_type
else
:
else
:
return
CTypedefType
(
cname
,
base_typ
e
,
is_external
)
return
CTypedefType
(
name
,
base_type
,
cnam
e
,
is_external
)
class
CTypedefType
(
BaseType
):
class
CTypedefType
(
BaseType
):
#
#
...
@@ -180,6 +180,7 @@ class CTypedefType(BaseType):
...
@@ -180,6 +180,7 @@ class CTypedefType(BaseType):
# HERE IS DELEGATED!
# HERE IS DELEGATED!
#
#
# qualified_name string
# qualified_name string
# typedef_name string
# typedef_cname string
# typedef_cname string
# typedef_base_type PyrexType
# typedef_base_type PyrexType
# typedef_is_external bool
# typedef_is_external bool
...
@@ -191,8 +192,9 @@ class CTypedefType(BaseType):
...
@@ -191,8 +192,9 @@ class CTypedefType(BaseType):
from_py_utility_code
=
None
from_py_utility_code
=
None
def
__init__
(
self
,
cname
,
base_typ
e
,
is_external
=
0
):
def
__init__
(
self
,
name
,
base_type
,
cnam
e
,
is_external
=
0
):
assert
not
base_type
.
is_complex
assert
not
base_type
.
is_complex
self
.
typedef_name
=
name
self
.
typedef_cname
=
cname
self
.
typedef_cname
=
cname
self
.
typedef_base_type
=
base_type
self
.
typedef_base_type
=
base_type
self
.
typedef_is_external
=
is_external
self
.
typedef_is_external
=
is_external
...
@@ -214,19 +216,12 @@ class CTypedefType(BaseType):
...
@@ -214,19 +216,12 @@ class CTypedefType(BaseType):
def
declaration_code
(
self
,
entity_code
,
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
name
=
self
.
declaration_name
(
for_display
,
pyrex
)
if
pyrex
or
for_display
:
if
pyrex
or
for_display
:
base_code
=
name
base_code
=
self
.
typedef_
name
else
:
else
:
base_code
=
public_decl
(
name
,
dll_linkage
)
base_code
=
public_decl
(
self
.
typedef_c
name
,
dll_linkage
)
return
self
.
base_declaration_code
(
base_code
,
entity_code
)
return
self
.
base_declaration_code
(
base_code
,
entity_code
)
def
declaration_name
(
self
,
for_display
=
0
,
pyrex
=
0
):
if
pyrex
or
for_display
:
return
self
.
qualified_name
else
:
return
self
.
typedef_cname
def
as_argument_type
(
self
):
def
as_argument_type
(
self
):
return
self
return
self
...
@@ -242,7 +237,7 @@ class CTypedefType(BaseType):
...
@@ -242,7 +237,7 @@ class CTypedefType(BaseType):
return
"<CTypedefType %s>"
%
self
.
typedef_cname
return
"<CTypedefType %s>"
%
self
.
typedef_cname
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
declaration_name
(
for_display
=
1
)
return
self
.
typedef_name
def
_create_utility_code
(
self
,
template_utility_code
,
def
_create_utility_code
(
self
,
template_utility_code
,
template_function_name
):
template_function_name
):
...
...
Cython/Compiler/Symtab.py
View file @
b93bc723
...
@@ -359,7 +359,8 @@ class Scope(object):
...
@@ -359,7 +359,8 @@ class Scope(object):
else:
else:
cname = self.mangle(Naming.type_prefix, name)
cname = self.mangle(Naming.type_prefix, name)
try:
try:
type = PyrexTypes.create_typedef_type(cname, base_type, (visibility == 'extern'))
type = PyrexTypes.create_typedef_type(name, base_type, cname,
(visibility == 'extern'))
except ValueError, e:
except ValueError, e:
error(pos, e.message)
error(pos, e.message)
type = PyrexTypes.error_type
type = PyrexTypes.error_type
...
...
tests/errors/e_excvalfunctype.pyx
View file @
b93bc723
...
@@ -7,6 +7,6 @@ cdef spamfunc spam
...
@@ -7,6 +7,6 @@ cdef spamfunc spam
grail
=
spam
# type mismatch
grail
=
spam
# type mismatch
spam
=
grail
# type mismatch
spam
=
grail
# type mismatch
_ERRORS
=
u"""
_ERRORS
=
u"""
7:28: Cannot assign type '
e_excvalfunctype.spamfunc' to 'e_excvalfunctype.
grailfunc'
7:28: Cannot assign type '
spamfunc' to '
grailfunc'
8:28: Cannot assign type '
e_excvalfunctype.grailfunc' to 'e_excvalfunctype.
spamfunc'
8:28: Cannot assign type '
grailfunc' to '
spamfunc'
"""
"""
tests/run/bufaccess.pyx
View file @
b93bc723
...
@@ -798,7 +798,7 @@ def printbuf_td_cy_int(object[td_cy_int] buf, shape):
...
@@ -798,7 +798,7 @@ def printbuf_td_cy_int(object[td_cy_int] buf, shape):
>>> printbuf_td_cy_int(ShortMockBuffer(None, range(3)), (3,))
>>> printbuf_td_cy_int(ShortMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Buffer dtype mismatch, expected '
bufaccess.
td_cy_int' but got 'short'
ValueError: Buffer dtype mismatch, expected 'td_cy_int' but got 'short'
"""
"""
cdef
int
i
cdef
int
i
for
i
in
range
(
shape
[
0
]):
for
i
in
range
(
shape
[
0
]):
...
@@ -813,7 +813,7 @@ def printbuf_td_h_short(object[td_h_short] buf, shape):
...
@@ -813,7 +813,7 @@ def printbuf_td_h_short(object[td_h_short] buf, shape):
>>> printbuf_td_h_short(IntMockBuffer(None, range(3)), (3,))
>>> printbuf_td_h_short(IntMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Buffer dtype mismatch, expected '
bufaccess.
td_h_short' but got 'int'
ValueError: Buffer dtype mismatch, expected 'td_h_short' but got 'int'
"""
"""
cdef
int
i
cdef
int
i
for
i
in
range
(
shape
[
0
]):
for
i
in
range
(
shape
[
0
]):
...
@@ -828,7 +828,7 @@ def printbuf_td_h_cy_short(object[td_h_cy_short] buf, shape):
...
@@ -828,7 +828,7 @@ def printbuf_td_h_cy_short(object[td_h_cy_short] buf, shape):
>>> printbuf_td_h_cy_short(IntMockBuffer(None, range(3)), (3,))
>>> printbuf_td_h_cy_short(IntMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Buffer dtype mismatch, expected '
bufaccess.
td_h_cy_short' but got 'int'
ValueError: Buffer dtype mismatch, expected 'td_h_cy_short' but got 'int'
"""
"""
cdef
int
i
cdef
int
i
for
i
in
range
(
shape
[
0
]):
for
i
in
range
(
shape
[
0
]):
...
@@ -843,7 +843,7 @@ def printbuf_td_h_ushort(object[td_h_ushort] buf, shape):
...
@@ -843,7 +843,7 @@ def printbuf_td_h_ushort(object[td_h_ushort] buf, shape):
>>> printbuf_td_h_ushort(ShortMockBuffer(None, range(3)), (3,))
>>> printbuf_td_h_ushort(ShortMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Buffer dtype mismatch, expected '
bufaccess.
td_h_ushort' but got 'short'
ValueError: Buffer dtype mismatch, expected 'td_h_ushort' but got 'short'
"""
"""
cdef
int
i
cdef
int
i
for
i
in
range
(
shape
[
0
]):
for
i
in
range
(
shape
[
0
]):
...
@@ -858,7 +858,7 @@ def printbuf_td_h_double(object[td_h_double] buf, shape):
...
@@ -858,7 +858,7 @@ def printbuf_td_h_double(object[td_h_double] buf, shape):
>>> printbuf_td_h_double(FloatMockBuffer(None, [0.25, 1, 3.125]), (3,))
>>> printbuf_td_h_double(FloatMockBuffer(None, [0.25, 1, 3.125]), (3,))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Buffer dtype mismatch, expected '
bufaccess.
td_h_double' but got 'float'
ValueError: Buffer dtype mismatch, expected 'td_h_double' but got 'float'
"""
"""
cdef
int
i
cdef
int
i
for
i
in
range
(
shape
[
0
]):
for
i
in
range
(
shape
[
0
]):
...
...
tests/run/embedsignatures.pyx
View file @
b93bc723
...
@@ -135,6 +135,12 @@ __doc__ = ur"""
...
@@ -135,6 +135,12 @@ __doc__ = ur"""
>>> print (f_D.__doc__)
>>> print (f_D.__doc__)
f_D(long double D) -> long double
f_D(long double D) -> long double
>>> print (f_my_i.__doc__)
f_my_i(MyInt i) -> MyInt
>>> print (f_my_f.__doc__)
f_my_f(MyFloat f) -> MyFloat
"""
"""
cdef
class
Ext
:
cdef
class
Ext
:
...
@@ -279,3 +285,11 @@ cpdef double f_d(double d):
...
@@ -279,3 +285,11 @@ cpdef double f_d(double d):
cpdef
long
double
f_D
(
long
double
D
):
cpdef
long
double
f_D
(
long
double
D
):
return
D
return
D
ctypedef
int
MyInt
cpdef
MyInt
f_my_i
(
MyInt
i
):
return
i
ctypedef
float
MyFloat
cpdef
MyFloat
f_my_f
(
MyFloat
f
):
return
f
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