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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
e84211b5
Commit
e84211b5
authored
Apr 19, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Buffer: Cleanup. There are no unsigned floats.
parent
5ba19402
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+16
-13
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+1
-1
No files found.
Cython/Compiler/Buffer.py
View file @
e84211b5
...
@@ -567,18 +567,21 @@ def create_typestringchecker(protocode, defcode, name, dtype):
...
@@ -567,18 +567,21 @@ def create_typestringchecker(protocode, defcode, name, dtype):
(
'b'
,
'char'
),
(
'h'
,
'short'
),
(
'i'
,
'int'
),
(
'b'
,
'char'
),
(
'h'
,
'short'
),
(
'i'
,
'int'
),
(
'l'
,
'long'
),
(
'q'
,
'long long'
)
(
'l'
,
'long'
),
(
'q'
,
'long long'
)
]
]
if
dtype
.
signed
==
0
:
for
char
,
against
in
types
:
defcode
.
putln
(
"case '%s': ok = (sizeof(%s) == sizeof(%s) && (%s)-1 > 0); break;"
%
(
char
.
upper
(),
ctype
,
against
,
ctype
))
else
:
for
char
,
against
in
types
:
defcode
.
putln
(
"case '%s': ok = (sizeof(%s) == sizeof(%s) && (%s)-1 < 0); break;"
%
(
char
,
ctype
,
against
,
ctype
))
elif
dtype
.
is_float
:
elif
dtype
.
is_float
:
types
=
[(
'f'
,
'float'
),
(
'd'
,
'double'
),
(
'g'
,
'long double'
)]
types
=
[(
'f'
,
'float'
),
(
'd'
,
'double'
),
(
'g'
,
'long double'
)]
else
:
assert
False
if
dtype
.
signed
==
0
:
for
char
,
against
in
types
:
for
char
,
against
in
types
:
defcode
.
putln
(
"case '%s': ok = (sizeof(%s) == sizeof(
unsigned %s) && (%s)-1 > 0
); break;"
%
defcode
.
putln
(
"case '%s': ok = (sizeof(%s) == sizeof(
%s)
); break;"
%
(
char
.
upper
(),
ctype
,
against
,
ctype
))
(
char
,
ctype
,
against
))
else
:
else
:
for
char
,
against
in
types
:
assert
False
defcode
.
putln
(
"case '%s': ok = (sizeof(%s) == sizeof(%s) && (%s)-1 < 0); break;"
%
(
char
,
ctype
,
against
,
ctype
))
defcode
.
putln
(
"default: ok = 0;"
)
defcode
.
putln
(
"default: ok = 0;"
)
defcode
.
putln
(
"}"
)
defcode
.
putln
(
"}"
)
put_assert
(
"ok"
,
"expected %s, got %%s"
%
dtype
)
put_assert
(
"ok"
,
"expected %s, got %%s"
%
dtype
)
...
@@ -670,11 +673,6 @@ def get_getbuffer_code(dtype, code):
...
@@ -670,11 +673,6 @@ def get_getbuffer_code(dtype, code):
__Pyx_BufferNdimError(buf, nd);
__Pyx_BufferNdimError(buf, nd);
goto fail;
goto fail;
}
}
if (buf->itemsize != sizeof(%(dtype_cname)s)) {
PyErr_SetString(PyExc_ValueError,
"Item size of buffer does not match size of %(dtype)s.");
goto fail;
}
if (!cast) {
if (!cast) {
ts = buf->format;
ts = buf->format;
ts = __Pyx_ConsumeWhitespace(ts);
ts = __Pyx_ConsumeWhitespace(ts);
...
@@ -690,6 +688,11 @@ def get_getbuffer_code(dtype, code):
...
@@ -690,6 +688,11 @@ def get_getbuffer_code(dtype, code):
goto fail;
goto fail;
}
}
}
}
if (buf->itemsize != sizeof(%(dtype_cname)s)) {
PyErr_SetString(PyExc_ValueError,
"Item size of buffer does not match size of '%(dtype)s'");
goto fail;
}
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
return 0;
return 0;
fail:;
fail:;
...
...
tests/run/bufaccess.pyx
View file @
e84211b5
...
@@ -1033,7 +1033,7 @@ def buffer_cast_fails(object[char, cast=True] buf):
...
@@ -1033,7 +1033,7 @@ def buffer_cast_fails(object[char, cast=True] buf):
>>> buffer_cast_fails(IntMockBuffer(None, [0]))
>>> buffer_cast_fails(IntMockBuffer(None, [0]))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError:
Attempted cast of buffer to datatype of different size.
ValueError:
Item size of buffer does not match size of 'char'
"""
"""
return
buf
[
0
]
return
buf
[
0
]
...
...
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