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
Xavier Thompson
cython
Commits
e27d9593
Commit
e27d9593
authored
Jun 15, 2011
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings from GCC -Wconversion
parent
48ef0a8b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
23 deletions
+25
-23
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+13
-15
Cython/Includes/numpy.pxd
Cython/Includes/numpy.pxd
+3
-3
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+9
-5
No files found.
Cython/Compiler/Buffer.py
View file @
e27d9593
...
...
@@ -744,7 +744,7 @@ typedef struct {
__Pyx_StructField root;
__Pyx_BufFmt_StackElem* head;
size_t fmt_offset;
in
t new_count, enc_count;
size_
t new_count, enc_count;
int is_complex;
char enc_type;
char new_packmode;
...
...
@@ -794,8 +794,8 @@ static int __Pyx_BufFmt_ParseNumber(const char** ts) {
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
char msg[] = {ch, 0};
PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%s'", msg
);
PyErr_Format(PyExc_ValueError,
"Unexpected format string character: '%c'", ch
);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
...
...
@@ -868,7 +868,7 @@ typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_s
_long_
long;
typedef struct { char c; PY_LONG_LONG x; } __Pyx_s
t_long
long;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) {
...
...
@@ -878,7 +878,7 @@ static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) {
case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(__Pyx_s
_long_
long) - sizeof(PY_LONG_LONG);
case 'q': case 'Q': return sizeof(__Pyx_s
t_long
long) - sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
...
...
@@ -890,7 +890,7 @@ static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) {
}
}
static
size_t
__Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
static
char
__Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
switch (ch) {
case 'c': case 'b': case 'h': case 'i': case 'l': case 'q': return 'I';
case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U';
...
...
@@ -944,8 +944,8 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
}
if (ctx->enc_packmode == '@') {
in
t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
in
t align_mod_offset;
size_
t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
size_
t align_mod_offset;
if (align_at == 0) return -1;
align_mod_offset = ctx->fmt_offset % align_at;
if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
...
...
@@ -1054,9 +1054,8 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
break;
case 'T': /* substruct */
{
int i;
const char* ts_after_sub;
int
struct_count = ctx->new_count;
size_t i,
struct_count = ctx->new_count;
ctx->new_count = 1;
++ts;
if (*ts != '{') {
...
...
@@ -1118,15 +1117,14 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
break;
default:
{
ctx->new_count = __Pyx_BufFmt_ParseNumber(&ts);
if (ctx->new_count == -1) { /* First char was not a digit */
char msg[2] = { *ts, 0 };
int number = __Pyx_BufFmt_ParseNumber(&ts);
if (number == -1) { /* First char was not a digit */
PyErr_Format(PyExc_ValueError,
"Does not understand character buffer dtype format string ('%
s')", msg
);
"Does not understand character buffer dtype format string ('%
c')", *ts
);
return NULL;
}
ctx->new_count = (size_t)number;
}
}
}
}
...
...
Cython/Includes/numpy.pxd
View file @
e27d9593
...
...
@@ -217,9 +217,9 @@ cdef extern from "numpy/arrayobject.h":
info
.
buf
=
PyArray_DATA
(
self
)
info
.
ndim
=
ndim
if
copy_shape
:
# Allocate new buffer for strides and shape info.
This is allocated
# as one block, strides first.
info
.
strides
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
sizeof
(
Py_ssize_t
)
*
ndim
*
2
)
# Allocate new buffer for strides and shape info.
#
This is allocated
as one block, strides first.
info
.
strides
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
sizeof
(
Py_ssize_t
)
*
<
size_t
>
ndim
*
2
)
info
.
shape
=
info
.
strides
+
ndim
for
i
in
range
(
ndim
):
info
.
strides
[
i
]
=
PyArray_STRIDES
(
self
)[
i
]
...
...
tests/run/bufaccess.pyx
View file @
e27d9593
...
...
@@ -1055,7 +1055,8 @@ cdef class MockBuffer:
stdlib
.
free
(
self
.
buffer
)
cdef
void
*
create_buffer
(
self
,
data
):
cdef
char
*
buf
=
<
char
*>
stdlib
.
malloc
(
len
(
data
)
*
self
.
itemsize
)
cdef
size_t
n
=
<
size_t
>
(
len
(
data
)
*
self
.
itemsize
)
cdef
char
*
buf
=
<
char
*>
stdlib
.
malloc
(
n
)
cdef
char
*
it
=
buf
for
value
in
data
:
self
.
write
(
it
,
value
)
...
...
@@ -1063,19 +1064,22 @@ cdef class MockBuffer:
return
buf
cdef
void
*
create_indirect_buffer
(
self
,
data
,
shape
):
cdef
size_t
n
=
0
cdef
void
**
buf
assert
shape
[
0
]
==
len
(
data
)
if
len
(
shape
)
==
1
:
return
self
.
create_buffer
(
data
)
else
:
shape
=
shape
[
1
:]
buf
=
<
void
**>
stdlib
.
malloc
(
len
(
data
)
*
sizeof
(
void
*
))
n
=
<
size_t
>
len
(
data
)
*
sizeof
(
void
*
)
buf
=
<
void
**>
stdlib
.
malloc
(
n
)
for
idx
,
subdata
in
enumerate
(
data
):
buf
[
idx
]
=
self
.
create_indirect_buffer
(
subdata
,
shape
)
return
buf
cdef
Py_ssize_t
*
list_to_sizebuf
(
self
,
l
):
cdef
Py_ssize_t
*
buf
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
len
(
l
)
*
sizeof
(
Py_ssize_t
))
cdef
size_t
n
=
<
size_t
>
len
(
l
)
*
sizeof
(
Py_ssize_t
)
cdef
Py_ssize_t
*
buf
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
n
)
for
i
,
x
in
enumerate
(
l
):
buf
[
i
]
=
x
return
buf
...
...
@@ -1128,7 +1132,7 @@ cdef class MockBuffer:
cdef
class
CharMockBuffer
(
MockBuffer
):
cdef
int
write
(
self
,
char
*
buf
,
object
value
)
except
-
1
:
(
<
char
*>
buf
)[
0
]
=
<
int
>
value
(
<
char
*>
buf
)[
0
]
=
<
char
>
value
return
0
cdef
get_itemsize
(
self
):
return
sizeof
(
char
)
cdef
get_default_format
(
self
):
return
b"@b"
...
...
@@ -1163,7 +1167,7 @@ cdef class UnsignedShortMockBuffer(MockBuffer):
cdef
class
FloatMockBuffer
(
MockBuffer
):
cdef
int
write
(
self
,
char
*
buf
,
object
value
)
except
-
1
:
(
<
float
*>
buf
)[
0
]
=
<
float
>
value
(
<
float
*>
buf
)[
0
]
=
<
float
>
(
<
double
>
value
)
return
0
cdef
get_itemsize
(
self
):
return
sizeof
(
float
)
cdef
get_default_format
(
self
):
return
b"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