Skip to content
GitLab
Menu
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
dynamic-graph-python
Commits
e2ce0682
Commit
e2ce0682
authored
Oct 16, 2012
by
Thomas Moulard
Browse files
Fix Ubuntu 12.04 (64 bits) portability issues.
parent
06e09ad4
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/convert-dg-to-py.cc
View file @
e2ce0682
...
...
@@ -62,10 +62,10 @@ namespace dynamicgraph {
std
::
string
svalue
;
Vector
v
;
Matrix
m
;
unsigned
in
t
nCols
;
unsigned
in
t
size
;
Py_ssize_
t
nCols
;
Py_ssize_
t
size
;
PyObject
*
row
;
unsigned
in
t
nRows
;
Py_ssize_
t
nRows
;
switch
(
valueType
)
{
case
(
Value
::
BOOL
)
:
...
...
@@ -81,7 +81,7 @@ namespace dynamicgraph {
throw
ExceptionPython
(
ExceptionPython
::
VALUE_PARSING
,
"unsigned int"
);
}
uvalue
=
PyInt_AsUnsignedLongMask
(
pyObject
);
uvalue
=
(
unsigned
int
)
PyInt_AsUnsignedLongMask
(
pyObject
);
return
Value
(
uvalue
);
break
;
case
(
Value
::
INT
)
:
...
...
@@ -109,7 +109,7 @@ namespace dynamicgraph {
dvalue
=
PyFloat_AsDouble
(
pyObject
);
return
Value
(
dvalue
);
}
else
if
(
PyInt_Check
(
pyObject
))
{
dvalue
=
0.0
+
PyInt_AS_LONG
(
pyObject
);
dvalue
=
(
double
)
PyInt_AS_LONG
(
pyObject
);
return
Value
(
dvalue
);
}
else
{
throw
ExceptionPython
(
ExceptionPython
::
VALUE_PARSING
,
...
...
@@ -162,7 +162,7 @@ namespace dynamicgraph {
}
nCols
=
PyTuple_Size
(
row
);
m
.
resize
(
nRows
,
nCols
);
m
.
resize
(
(
unsigned
int
)
nRows
,
(
unsigned
int
)
nCols
);
fillMatrixRow
(
m
,
0
,
row
);
for
(
unsigned
int
iRow
=
1
;
iRow
<
nRows
;
iRow
++
)
{
...
...
src/entity-py.cc
View file @
e2ce0682
...
...
@@ -193,7 +193,7 @@ namespace dynamicgraph {
PyErr_SetString
(
PyExc_TypeError
,
"third argument is not a tuple"
);
return
NULL
;
}
unsigned
in
t
size
=
PyTuple_Size
(
argTuple
);
Py_ssize_
t
size
=
PyTuple_Size
(
argTuple
);
std
::
map
<
const
std
::
string
,
Command
*>
commandMap
=
entity
->
getNewStyleCommandMap
();
...
...
@@ -208,13 +208,14 @@ namespace dynamicgraph {
Command
*
command
=
commandMap
[
std
::
string
(
commandName
)];
// Check that tuple size is equal to command number of arguments
const
std
::
vector
<
Value
::
Type
>
typeVector
=
command
->
valueTypes
();
if
(
size
!=
typeVector
.
size
())
{
std
::
stringstream
ss
;
ss
<<
"command takes "
<<
typeVector
.
size
()
<<
" parameters, "
<<
size
<<
" given."
;
PyErr_SetString
(
dgpyError
,
ss
.
str
().
c_str
());
return
NULL
;
}
if
((
unsigned
)
size
!=
typeVector
.
size
())
{
std
::
stringstream
ss
;
ss
<<
"command takes "
<<
typeVector
.
size
()
<<
" parameters, "
<<
size
<<
" given."
;
PyErr_SetString
(
dgpyError
,
ss
.
str
().
c_str
());
return
NULL
;
}
std
::
vector
<
Value
>
valueVector
;
for
(
unsigned
int
iParam
=
0
;
iParam
<
size
;
iParam
++
)
{
...
...
@@ -257,9 +258,10 @@ namespace dynamicgraph {
}
void
*
pointer
=
PyCObject_AsVoidPtr
(
object
);
Entity
*
entity
=
(
Entity
*
)
pointer
;
typedef
std
::
map
<
const
std
::
string
,
command
::
Command
*>
CommandMap
;
typedef
std
::
map
<
const
std
::
string
,
command
::
Command
*>
CommandMap
;
CommandMap
map
=
entity
->
getNewStyleCommandMap
();
unsigned
in
t
nbCommands
=
map
.
size
();
Py_ssize_
t
nbCommands
=
(
Py_ssize_t
)
map
.
size
();
// Create a tuple of same size as the command map
PyObject
*
result
=
PyTuple_New
(
nbCommands
);
unsigned
int
count
=
0
;
...
...
src/factory-py.cc
View file @
e2ce0682
...
...
@@ -34,15 +34,20 @@ namespace dynamicgraph {
return
NULL
;
std
::
vector
<
std
::
string
>
classNames
;
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
listEntities
(
classNames
);
unsigned
int
classNumber
=
classNames
.
size
();
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
listEntities
(
classNames
);
Py_ssize_t
classNumber
=
classNames
.
size
();
// Build a tuple object
PyObject
*
classTuple
=
PyTuple_New
(
classNumber
);
for
(
unsigned
int
iEntity
=
0
;
iEntity
<
classNames
.
size
();
iEntity
++
)
{
PyObject
*
className
=
Py_BuildValue
(
"s"
,
classNames
[
iEntity
].
c_str
());
PyTuple_SetItem
(
classTuple
,
iEntity
,
className
);
}
for
(
Py_ssize_t
iEntity
=
0
;
iEntity
<
(
Py_ssize_t
)
classNames
.
size
();
++
iEntity
)
{
PyObject
*
className
=
Py_BuildValue
(
"s"
,
classNames
[
iEntity
].
c_str
());
PyTuple_SetItem
(
classTuple
,
iEntity
,
className
);
}
return
Py_BuildValue
(
"O"
,
classTuple
);
}
...
...
src/interpreter.cc
View file @
e2ce0682
...
...
@@ -68,11 +68,12 @@ bool HandleErr(std::string & err,
PyTuple_SET_ITEM
(
args
,
2
,
ptraceback
);
pyerr
=
PyObject_CallObject
(
traceback_format_exception
,
args
);
assert
(
PyList_Check
(
pyerr
));
unsigned
in
t
size
=
PyList_GET_SIZE
(
pyerr
);
Py_ssize_
t
size
=
PyList_GET_SIZE
(
pyerr
);
std
::
string
stringRes
;
for
(
unsigned
int
i
=
0
;
i
<
size
;
i
++
)
{
stringRes
+=
std
::
string
(
PyString_AsString
(
PyList_GET_ITEM
(
pyerr
,
i
)));
}
for
(
Py_ssize_t
i
=
0
;
i
<
size
;
++
i
)
stringRes
+=
std
::
string
(
PyString_AsString
(
PyList_GET_ITEM
(
pyerr
,
i
)));
pyerr
=
PyString_FromString
(
stringRes
.
c_str
());
err
=
PyString_AsString
(
pyerr
);
dgDEBUG
(
15
)
<<
"err: "
<<
err
<<
std
::
endl
;
...
...
src/signal-caster-py.cc
View file @
e2ce0682
...
...
@@ -29,13 +29,15 @@ namespace dynamicgraph {
return
NULL
;
std
::
vector
<
std
::
string
>
typeList
=
dynamicgraph
::
SignalCaster
::
getInstance
()
->
listTypenames
();
unsigned
in
t
typeNumber
=
typeList
.
size
();
Py_ssize_
t
typeNumber
=
typeList
.
size
();
// Build a tuple object
PyObject
*
typeTuple
=
PyTuple_New
(
typeNumber
);
for
(
unsigned
int
iType
=
0
;
iType
<
typeNumber
;
iType
++
)
{
PyObject
*
className
=
Py_BuildValue
(
"s"
,
typeList
[
iType
].
c_str
());
PyTuple_SetItem
(
typeTuple
,
iType
,
className
);
for
(
Py_ssize_t
iType
=
0
;
iType
<
typeNumber
;
++
iType
)
{
PyObject
*
className
=
Py_BuildValue
(
"s"
,
typeList
[
iType
].
c_str
());
PyTuple_SetItem
(
typeTuple
,
iType
,
className
);
}
return
Py_BuildValue
(
"O"
,
typeTuple
);
...
...
Write
Preview
Supports
Markdown
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