Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eigenpy
Commits
42e4faa3
Verified
Commit
42e4faa3
authored
Jul 17, 2021
by
Justin Carpentier
Browse files
core: add alignment value automatically deduced
parent
fdfaa736
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/eigenpy/register.hpp
View file @
42e4faa3
...
...
@@ -79,6 +79,7 @@ namespace eigenpy
static
int
registerNewType
(
PyTypeObject
*
py_type_ptr
,
const
std
::
type_info
*
type_info_ptr
,
const
int
type_size
,
const
int
alignment
,
PyArray_GetItemFunc
*
getitem
,
PyArray_SetItemFunc
*
setitem
,
PyArray_NonzeroFunc
*
nonzero
,
...
...
include/eigenpy/user-type.hpp
View file @
42e4faa3
...
...
@@ -27,6 +27,18 @@ namespace eigenpy
// static void cast(void * /*from*/, void * /*to*/, npy_intp /*n*/, void * /*fromarr*/, void * /*toarr*/) {};
};
template
<
typename
T
>
struct
OffsetOf
{
struct
Data
{
char
c
;
T
v
;
};
enum
{
value
=
offsetof
(
Data
,
v
)
};
};
template
<
typename
T
>
struct
SpecialMethods
<
T
,
NPY_USERDEF
>
{
...
...
@@ -194,6 +206,7 @@ namespace eigenpy
int
code
=
Register
::
registerNewType
(
py_type_ptr
,
&
typeid
(
Scalar
),
sizeof
(
Scalar
),
internal
::
OffsetOf
<
Scalar
>::
value
,
getitem
,
setitem
,
nonzero
,
copyswap
,
copyswapn
,
dotfunc
);
...
...
src/register.cpp
View file @
42e4faa3
...
...
@@ -36,6 +36,7 @@ namespace eigenpy
int
Register
::
registerNewType
(
PyTypeObject
*
py_type_ptr
,
const
std
::
type_info
*
type_info_ptr
,
const
int
type_size
,
const
int
alignement
,
PyArray_GetItemFunc
*
getitem
,
PyArray_SetItemFunc
*
setitem
,
PyArray_NonzeroFunc
*
nonzero
,
...
...
@@ -68,7 +69,7 @@ namespace eigenpy
descr
.
type_num
=
0
;
descr
.
names
=
0
;
descr
.
fields
=
0
;
descr
.
alignment
=
call_PyArray_DescrFromType
(
NPY_OBJECT
)
->
alignment
;
descr
.
alignment
=
alignement
;
//
call_PyArray_DescrFromType(NPY_OBJECT)->alignment;
PyArray_ArrFuncs
*
funcs_ptr
=
new
PyArray_ArrFuncs
;
PyArray_ArrFuncs
&
funcs
=
*
funcs_ptr
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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