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
85c37d2d
Commit
85c37d2d
authored
Oct 11, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
f12d22b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
57 deletions
+0
-57
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+0
-57
No files found.
Cython/Compiler/Buffer.py
View file @
85c37d2d
...
...
@@ -505,63 +505,6 @@ def mangle_dtype_name(dtype):
prefix
=
""
return
prefix
+
dtype
.
declaration_code
(
""
).
replace
(
" "
,
"_"
)
def
get_ts_check_item
(
dtype
,
writer
):
# See if we can consume one (unnamed) dtype as next item
# Put native and custom types in seperate namespaces (as one could create a type named unsigned_int...)
name
=
"__Pyx_CheckTypestringItem_%s"
%
mangle_dtype_name
(
dtype
)
if
not
writer
.
globalstate
.
has_code
(
name
):
char
=
dtype
.
typestring
if
char
is
not
None
:
assert
len
(
char
)
==
1
# Can use direct comparison
code
=
dedent
(
"""
\
if (*ts != '%s') {
PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (expected '%s', got '%%s')", ts);
return NULL;
} else return ts + 1;
"""
,
2
)
%
(
char
,
char
)
else
:
# Cannot trust declared size; but rely on int vs float and
# signed/unsigned to be correctly declared
ctype
=
dtype
.
declaration_code
(
""
)
code
=
dedent
(
"""
\
int ok;
switch (*ts) {"""
,
2
)
if
dtype
.
is_int
:
types
=
[
(
'b'
,
'char'
),
(
'h'
,
'short'
),
(
'i'
,
'int'
),
(
'l'
,
'long'
),
(
'q'
,
'long long'
)
]
elif
dtype
.
is_float
:
types
=
[(
'f'
,
'float'
),
(
'd'
,
'double'
),
(
'g'
,
'long double'
)]
else
:
assert
False
if
dtype
.
signed
==
0
:
code
+=
""
.
join
([
"
\
n
case '%s': ok = (sizeof(%s) == sizeof(%s) && (%s)-1 > 0); break;"
%
(
char
.
upper
(),
ctype
,
against
,
ctype
)
for
char
,
against
in
types
])
else
:
code
+=
""
.
join
([
"
\
n
case '%s': ok = (sizeof(%s) == sizeof(%s) && (%s)-1 < 0); break;"
%
(
char
,
ctype
,
against
,
ctype
)
for
char
,
against
in
types
])
code
+=
dedent
(
"""
\
default: ok = 0;
}
if (!ok) {
PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%s')", ts);
return NULL;
} else return ts + 1;
"""
,
2
)
writer
.
globalstate
.
use_utility_code
([
dedent
(
"""
\
static const char* %s(const char* ts); /*proto*/
"""
)
%
name
,
dedent
(
"""
static const char* %s(const char* ts) {
%s
}
"""
)
%
(
name
,
code
)],
name
=
name
)
return
name
def
get_typestringchecker
(
code
,
dtype
):
"""
Returns the name of a typestring checker with the given type; emitting
...
...
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