Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit ccbcc4a

Browse files
committed
[Python2] fix compilation
1 parent dab6fee commit ccbcc4a

File tree

5 files changed

+262
-38
lines changed

5 files changed

+262
-38
lines changed

src/dynamic_graph/debug-py.cc

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ namespace debug {
2525

2626
std::map<std::string, ofstreamShrPtr> mapOfFiles_;
2727

28-
PyObject* addLoggerFileOutputStream(PyObject* m, PyObject* args) {
28+
PyObject* addLoggerFileOutputStream(
29+
#if PY_MAJOR_VERSION >= 3
30+
PyObject* m, PyObject* args
31+
#else
32+
PyObject*, PyObject* args
33+
#endif
34+
) {
2935
char* filename;
3036
if (!PyArg_ParseTuple(args, "s", &filename)) return NULL;
3137
std::string sfilename(filename);
@@ -42,7 +48,13 @@ PyObject* addLoggerFileOutputStream(PyObject* m, PyObject* args) {
4248
return Py_BuildValue("");
4349
}
4450

45-
PyObject* closeLoggerFileOutputStream(PyObject* m, PyObject* /*args */) {
51+
PyObject* closeLoggerFileOutputStream(
52+
#if PY_MAJOR_VERSION >= 3
53+
PyObject* m, PyObject*
54+
#else
55+
PyObject*, PyObject*
56+
#endif
57+
) {
4658
try {
4759
for (std::map<std::string, ofstreamShrPtr>::iterator it = mapOfFiles_.begin(); it != mapOfFiles_.end(); ++it) {
4860
it->second->close();
@@ -52,31 +64,55 @@ PyObject* closeLoggerFileOutputStream(PyObject* m, PyObject* /*args */) {
5264
return Py_BuildValue("");
5365
}
5466

55-
PyObject* addLoggerCoutOutputStream(PyObject* m, PyObject* /*args*/) {
67+
PyObject* addLoggerCoutOutputStream(
68+
#if PY_MAJOR_VERSION >= 3
69+
PyObject* m, PyObject*
70+
#else
71+
PyObject*, PyObject*
72+
#endif
73+
) {
5674
try {
5775
dgADD_OSTREAM_TO_RTLOG(std::cout);
5876
}
5977
CATCH_ALL_EXCEPTIONS(m);
6078
return Py_BuildValue("");
6179
}
6280

63-
PyObject* realTimeLoggerDestroy(PyObject* m, PyObject* /*args*/) {
81+
PyObject* realTimeLoggerDestroy(
82+
#if PY_MAJOR_VERSION >= 3
83+
PyObject* m, PyObject*
84+
#else
85+
PyObject*, PyObject*
86+
#endif
87+
) {
6488
try {
6589
RealTimeLogger::destroy();
6690
}
6791
CATCH_ALL_EXCEPTIONS(m);
6892
return Py_BuildValue("");
6993
}
7094

71-
PyObject* realTimeLoggerSpinOnce(PyObject* m, PyObject* /*args*/) {
95+
PyObject* realTimeLoggerSpinOnce(
96+
#if PY_MAJOR_VERSION >= 3
97+
PyObject* m, PyObject*
98+
#else
99+
PyObject*, PyObject*
100+
#endif
101+
) {
72102
try {
73103
RealTimeLogger::instance().spinOnce();
74104
}
75105
CATCH_ALL_EXCEPTIONS(m);
76106
return Py_BuildValue("");
77107
}
78108

79-
PyObject* realTimeLoggerInstance(PyObject* m, PyObject* /*args*/) {
109+
PyObject* realTimeLoggerInstance(
110+
#if PY_MAJOR_VERSION >= 3
111+
PyObject* m, PyObject*
112+
#else
113+
PyObject*, PyObject*
114+
#endif
115+
) {
80116
try {
81117
RealTimeLogger::instance();
82118
}

src/dynamic_graph/dynamic-graph-py.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ namespace python {
1717
/**
1818
\brief plug a signal into another one.
1919
*/
20-
PyObject* plug(PyObject* m, PyObject* args) {
20+
PyObject* plug(
21+
#if PY_MAJOR_VERSION >= 3
22+
PyObject* m, PyObject* args
23+
#else
24+
PyObject*, PyObject* args
25+
#endif
26+
) {
2127
PyObject* objOut = NULL;
2228
PyObject* objIn = NULL;
2329
void* pObjOut;
@@ -65,7 +71,13 @@ PyObject* plug(PyObject* m, PyObject* args) {
6571
return Py_BuildValue("");
6672
}
6773

68-
PyObject* enableTrace(PyObject* m, PyObject* args) {
74+
PyObject* enableTrace(
75+
#if PY_MAJOR_VERSION >= 3
76+
PyObject* m, PyObject* args
77+
#else
78+
PyObject*, PyObject* args
79+
#endif
80+
) {
6981
PyObject* boolean;
7082
char* filename = NULL;
7183

@@ -140,7 +152,7 @@ void initwrap(void)
140152
Py_XDECREF(st->dgpyError);
141153
Py_CLEAR(st->dgpyError);
142154
Py_DECREF(module);
143-
return NULL;
155+
INITERROR;
144156
}
145157

146158
#if PY_MAJOR_VERSION >= 3

src/dynamic_graph/entity-py.cc

Lines changed: 105 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ namespace entity {
3737
/**
3838
\brief Create an instance of Entity
3939
*/
40-
PyObject* create(PyObject* m, PyObject* args) {
40+
PyObject* create(
41+
#if PY_MAJOR_VERSION >= 3
42+
PyObject* m, PyObject* args
43+
#else
44+
PyObject*, PyObject* args
45+
#endif
46+
) {
4147
char* className = NULL;
4248
char* instanceName = NULL;
4349

@@ -69,7 +75,13 @@ PyObject* create(PyObject* m, PyObject* args) {
6975
/**
7076
\brief Get name of entity
7177
*/
72-
PyObject* getName(PyObject* m, PyObject* args) {
78+
PyObject* getName(
79+
#if PY_MAJOR_VERSION >= 3
80+
PyObject* m, PyObject* args
81+
#else
82+
PyObject*, PyObject* args
83+
#endif
84+
) {
7385
PyObject* object = NULL;
7486
void* pointer = NULL;
7587
std::string name;
@@ -93,7 +105,13 @@ PyObject* getName(PyObject* m, PyObject* args) {
93105
/**
94106
\brief Get class name of entity
95107
*/
96-
PyObject* getClassName(PyObject* m, PyObject* args) {
108+
PyObject* getClassName(
109+
#if PY_MAJOR_VERSION >= 3
110+
PyObject* m, PyObject* args
111+
#else
112+
PyObject*, PyObject* args
113+
#endif
114+
) {
97115
PyObject* object = NULL;
98116
void* pointer = NULL;
99117
std::string name;
@@ -117,7 +135,13 @@ PyObject* getClassName(PyObject* m, PyObject* args) {
117135
/**
118136
\brief Check if the entity has a signal with the given name
119137
*/
120-
PyObject* hasSignal(PyObject* m, PyObject* args) {
138+
PyObject* hasSignal(
139+
#if PY_MAJOR_VERSION >= 3
140+
PyObject* m, PyObject* args
141+
#else
142+
PyObject*, PyObject* args
143+
#endif
144+
) {
121145
char* name = NULL;
122146
PyObject* object = NULL;
123147
void* pointer = NULL;
@@ -147,7 +171,13 @@ PyObject* hasSignal(PyObject* m, PyObject* args) {
147171
/**
148172
\brief Get a signal by name
149173
*/
150-
PyObject* getSignal(PyObject* m, PyObject* args) {
174+
PyObject* getSignal(
175+
#if PY_MAJOR_VERSION >= 3
176+
PyObject* m, PyObject* args
177+
#else
178+
PyObject*, PyObject* args
179+
#endif
180+
) {
151181
char* name = NULL;
152182
PyObject* object = NULL;
153183
void* pointer = NULL;
@@ -173,7 +203,13 @@ PyObject* getSignal(PyObject* m, PyObject* args) {
173203
return PyCapsule_New((void*)signal, "dynamic_graph.Signal", NULL);
174204
}
175205

176-
PyObject* listSignals(PyObject* m, PyObject* args) {
206+
PyObject* listSignals(
207+
#if PY_MAJOR_VERSION >= 3
208+
PyObject* m, PyObject* args
209+
#else
210+
PyObject*, PyObject* args
211+
#endif
212+
) {
177213
void* pointer = NULL;
178214
PyObject* object = NULL;
179215

@@ -298,7 +334,13 @@ PyObject* listCommands(PyObject* /*self*/, PyObject* args) {
298334
}
299335
return result;
300336
}
301-
PyObject* getCommandDocstring(PyObject* m, PyObject* args) {
337+
PyObject* getCommandDocstring(
338+
#if PY_MAJOR_VERSION >= 3
339+
PyObject* m, PyObject* args
340+
#else
341+
PyObject*, PyObject* args
342+
#endif
343+
) {
302344
PyObject* object = NULL;
303345
char* commandName;
304346
if (!PyArg_ParseTuple(args, "Os", &object, &commandName)) {
@@ -328,7 +370,13 @@ PyObject* getCommandDocstring(PyObject* m, PyObject* args) {
328370
return Py_BuildValue("s", docstring.c_str());
329371
}
330372

331-
PyObject* getDocString(PyObject* m, PyObject* args) {
373+
PyObject* getDocString(
374+
#if PY_MAJOR_VERSION >= 3
375+
PyObject* m, PyObject* args
376+
#else
377+
PyObject*, PyObject* args
378+
#endif
379+
) {
332380
PyObject* object = NULL;
333381
if (!PyArg_ParseTuple(args, "O", &object)) {
334382
return NULL;
@@ -353,7 +401,13 @@ PyObject* getDocString(PyObject* m, PyObject* args) {
353401
return NULL;
354402
}
355403

356-
PyObject* display(PyObject* m, PyObject* args) {
404+
PyObject* display(
405+
#if PY_MAJOR_VERSION >= 3
406+
PyObject* m, PyObject* args
407+
#else
408+
PyObject*, PyObject* args
409+
#endif
410+
) {
357411
/* Retrieve the entity instance. */
358412
PyObject* object = NULL;
359413
if (!PyArg_ParseTuple(args, "O", &object) || (!PyCapsule_CheckExact(object))) {
@@ -374,7 +428,13 @@ PyObject* display(PyObject* m, PyObject* args) {
374428
/**
375429
\brief Set verbosity Level
376430
*/
377-
PyObject* setLoggerVerbosityLevel(PyObject* m, PyObject* args) {
431+
PyObject* setLoggerVerbosityLevel(
432+
#if PY_MAJOR_VERSION >= 3
433+
PyObject* m, PyObject* args
434+
#else
435+
PyObject*, PyObject* args
436+
#endif
437+
) {
378438
PyObject* object = NULL;
379439
PyObject* objectVerbosityLevel = NULL;
380440
if (!PyArg_ParseTuple(args, "OO", &object, &objectVerbosityLevel)) return NULL;
@@ -430,7 +490,13 @@ PyObject* setLoggerVerbosityLevel(PyObject* m, PyObject* args) {
430490
/**
431491
\brief Get verbosity Level
432492
*/
433-
PyObject* getLoggerVerbosityLevel(PyObject* m, PyObject* args) {
493+
PyObject* getLoggerVerbosityLevel(
494+
#if PY_MAJOR_VERSION >= 3
495+
PyObject* m, PyObject* args
496+
#else
497+
PyObject*, PyObject* args
498+
#endif
499+
) {
434500
PyObject* object = NULL;
435501
if (!PyArg_ParseTuple(args, "O", &object)) return NULL;
436502

@@ -456,7 +522,13 @@ PyObject* getLoggerVerbosityLevel(PyObject* m, PyObject* args) {
456522
/**
457523
\brief Get stream print period
458524
*/
459-
PyObject* getStreamPrintPeriod(PyObject* m, PyObject* args) {
525+
PyObject* getStreamPrintPeriod(
526+
#if PY_MAJOR_VERSION >= 3
527+
PyObject* m, PyObject* args
528+
#else
529+
PyObject*, PyObject* args
530+
#endif
531+
) {
460532
PyObject* object = NULL;
461533
if (!PyArg_ParseTuple(args, "O", &object)) return NULL;
462534

@@ -481,7 +553,13 @@ PyObject* getStreamPrintPeriod(PyObject* m, PyObject* args) {
481553
/**
482554
\brief Set print period
483555
*/
484-
PyObject* setStreamPrintPeriod(PyObject* m, PyObject* args) {
556+
PyObject* setStreamPrintPeriod(
557+
#if PY_MAJOR_VERSION >= 3
558+
PyObject* m, PyObject* args
559+
#else
560+
PyObject*, PyObject* args
561+
#endif
562+
) {
485563
PyObject* object = NULL;
486564
double streamPrintPeriod = 0;
487565
if (!PyArg_ParseTuple(args, "Od", &object, &streamPrintPeriod)) return NULL;
@@ -515,7 +593,13 @@ PyObject* setStreamPrintPeriod(PyObject* m, PyObject* args) {
515593
/**
516594
\brief Get stream print period
517595
*/
518-
PyObject* getTimeSample(PyObject* m, PyObject* args) {
596+
PyObject* getTimeSample(
597+
#if PY_MAJOR_VERSION >= 3
598+
PyObject* m, PyObject* args
599+
#else
600+
PyObject*, PyObject* args
601+
#endif
602+
) {
519603
PyObject* object = NULL;
520604
if (!PyArg_ParseTuple(args, "O", &object)) return NULL;
521605

@@ -540,7 +624,13 @@ PyObject* getTimeSample(PyObject* m, PyObject* args) {
540624
/**
541625
\brief Set time sample
542626
*/
543-
PyObject* setTimeSample(PyObject* m, PyObject* args) {
627+
PyObject* setTimeSample(
628+
#if PY_MAJOR_VERSION >= 3
629+
PyObject* m, PyObject* args
630+
#else
631+
PyObject*, PyObject* args
632+
#endif
633+
) {
544634
PyObject* object = NULL;
545635
double timeSample;
546636
if (!PyArg_ParseTuple(args, "Od", &object, &timeSample)) return NULL;

src/dynamic_graph/pool-py.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ namespace python {
1212

1313
namespace pool {
1414

15-
PyObject* writeGraph(PyObject* m, PyObject* args) {
15+
PyObject* writeGraph(
16+
#if PY_MAJOR_VERSION >= 3
17+
PyObject* m, PyObject* args
18+
#else
19+
PyObject*, PyObject* args
20+
#endif
21+
) {
1622
char* filename;
1723
if (!PyArg_ParseTuple(args, "s", &filename)) return NULL;
1824
try {
@@ -25,7 +31,13 @@ PyObject* writeGraph(PyObject* m, PyObject* args) {
2531
/**
2632
\brief Get list of entities
2733
*/
28-
PyObject* getEntityList(PyObject* m, PyObject* args) {
34+
PyObject* getEntityList(
35+
#if PY_MAJOR_VERSION >= 3
36+
PyObject* m, PyObject* args
37+
#else
38+
PyObject*, PyObject* args
39+
#endif
40+
) {
2941
if (!PyArg_ParseTuple(args, "")) return NULL;
3042

3143
std::vector<std::string> entityNames;

0 commit comments

Comments
 (0)