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
e17c1f59
Commit
e17c1f59
authored
Dec 10, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align on first member of nested struct if first member in struct
parent
cf9598f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
Cython/Utility/Buffer.c
Cython/Utility/Buffer.c
+6
-1
tests/run/memslice.pyx
tests/run/memslice.pyx
+26
-0
No files found.
Cython/Utility/Buffer.c
View file @
e17c1f59
...
@@ -489,6 +489,7 @@ __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
...
@@ -489,6 +489,7 @@ __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
static
const
char
*
__Pyx_BufFmt_CheckString
(
__Pyx_BufFmt_Context
*
ctx
,
const
char
*
ts
)
{
static
const
char
*
__Pyx_BufFmt_CheckString
(
__Pyx_BufFmt_Context
*
ctx
,
const
char
*
ts
)
{
int
got_Z
=
0
;
int
got_Z
=
0
;
while
(
1
)
{
while
(
1
)
{
switch
(
*
ts
)
{
switch
(
*
ts
)
{
case
0
:
case
0
:
...
@@ -533,20 +534,24 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
...
@@ -533,20 +534,24 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
{
{
const
char
*
ts_after_sub
;
const
char
*
ts_after_sub
;
size_t
i
,
struct_count
=
ctx
->
new_count
;
size_t
i
,
struct_count
=
ctx
->
new_count
;
size_t
struct_alignment
=
ctx
->
struct_alignment
;
ctx
->
new_count
=
1
;
ctx
->
new_count
=
1
;
++
ts
;
++
ts
;
if
(
*
ts
!=
'{'
)
{
if
(
*
ts
!=
'{'
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Buffer acquisition: Expected '{' after 'T'"
);
PyErr_SetString
(
PyExc_ValueError
,
"Buffer acquisition: Expected '{' after 'T'"
);
return
NULL
;
return
NULL
;
}
}
if
(
__Pyx_BufFmt_ProcessTypeChunk
(
ctx
)
==
-
1
)
return
NULL
;
ctx
->
enc_type
=
0
;
/* Erase processed last struct element */
ctx
->
struct_alignment
=
0
;
++
ts
;
++
ts
;
ts_after_sub
=
ts
;
ts_after_sub
=
ts
;
ctx
->
struct_alignment
=
0
;
for
(
i
=
0
;
i
!=
struct_count
;
++
i
)
{
for
(
i
=
0
;
i
!=
struct_count
;
++
i
)
{
ts_after_sub
=
__Pyx_BufFmt_CheckString
(
ctx
,
ts
);
ts_after_sub
=
__Pyx_BufFmt_CheckString
(
ctx
,
ts
);
if
(
!
ts_after_sub
)
return
NULL
;
if
(
!
ts_after_sub
)
return
NULL
;
}
}
ts
=
ts_after_sub
;
ts
=
ts_after_sub
;
if
(
struct_alignment
)
ctx
->
struct_alignment
=
struct_alignment
;
}
}
break
;
break
;
case
'}'
:
/* end of substruct; either repeat or move on */
case
'}'
:
/* end of substruct; either repeat or move on */
...
...
tests/run/memslice.pyx
View file @
e17c1f59
...
@@ -1538,11 +1538,37 @@ cdef struct AlignedNestedNormal:
...
@@ -1538,11 +1538,37 @@ cdef struct AlignedNestedNormal:
PaddedAtEndNormal
a
PaddedAtEndNormal
a
char
chars
char
chars
# Test nested structs in a struct, make sure we compute padding each time
# accordingly. If the first struct member is a struct, align on the first
# member of that struct (recursively)
cdef
struct
A
:
double
d
char
c
cdef
struct
B
:
char
c1
A
a
char
c2
cdef
struct
C
:
A
a
char
c1
cdef
struct
D
:
B
b
C
cstruct
int
a
[
2
]
char
c
cdef
fused
FusedPadded
:
cdef
fused
FusedPadded
:
ArrayStruct
ArrayStruct
PackedArrayStruct
PackedArrayStruct
AlignedNested
AlignedNested
AlignedNestedNormal
AlignedNestedNormal
A
B
C
D
@
testcase
@
testcase
def
test_padded_structs
():
def
test_padded_structs
():
...
...
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