Skip to content

Commit 8dbedc6

Browse files
committed
unifying return value #15949
1 parent 9259766 commit 8dbedc6

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

src/libsumo/libsumo_typemap.i

+10-10
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,18 @@ static PyObject* parseSubscriptionMap(const std::map<int, std::shared_ptr<libsum
233233
};
234234

235235
%typemap(out) std::vector<libsumo::TraCIConnection> {
236-
$result = PyList_New($1.size());
236+
$result = PyTuple_New($1.size());
237237
int index = 0;
238238
for (auto iter = $1.begin(); iter != $1.end(); ++iter) {
239-
PyList_SetItem($result, index++, Py_BuildValue("(sNNNsssd)",
240-
iter->approachedLane.c_str(),
241-
PyBool_FromLong(iter->hasPrio),
242-
PyBool_FromLong(iter->isOpen),
243-
PyBool_FromLong(iter->hasFoe),
244-
iter->approachedInternal.c_str(),
245-
iter->state.c_str(),
246-
iter->direction.c_str(),
247-
iter->length));
239+
PyTuple_SetItem($result, index++, Py_BuildValue("(sNNNsssd)",
240+
iter->approachedLane.c_str(),
241+
PyBool_FromLong(iter->hasPrio),
242+
PyBool_FromLong(iter->isOpen),
243+
PyBool_FromLong(iter->hasFoe),
244+
iter->approachedInternal.c_str(),
245+
iter->state.c_str(),
246+
iter->direction.c_str(),
247+
iter->length));
248248
}
249249
};
250250

tools/traci/_lane.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _readLinks(result):
4646
length = result.readDouble()
4747
links.append((approachedLane, hasPrio, isOpen, hasFoe,
4848
approachedInternal, state, direction, length))
49-
return links
49+
return tuple(links)
5050

5151

5252
_RETURN_VALUE_FUNC = {tc.LANE_LINKS: _readLinks}

tools/traci/_vehicle.py

+2-27
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from ._vehicletype import VTypeDomain
2929
from . import constants as tc
3030
from .exceptions import TraCIException, deprecated, alias_param
31+
from ._lane import _readLinks
3132

3233

3334
_legacyGetLeader = True
@@ -204,32 +205,6 @@ def _readNextStops(result):
204205
return tuple(nextStop)
205206

206207

207-
def _readNextLinks(result):
208-
result.read("!Bi") # Type Compound, Length
209-
nbLinks = result.readInt()
210-
links = []
211-
for _ in range(nbLinks):
212-
result.read("!B") # Type String
213-
approachedLane = result.readString()
214-
result.read("!B") # Type String
215-
approachedInternal = result.readString()
216-
result.read("!B") # Type Byte
217-
hasPrio = bool(result.read("!B")[0])
218-
result.read("!B") # Type Byte
219-
isOpen = bool(result.read("!B")[0])
220-
result.read("!B") # Type Byte
221-
hasFoe = bool(result.read("!B")[0])
222-
result.read("!B") # Type String
223-
state = result.readString()
224-
result.read("!B") # Type String
225-
direction = result.readString()
226-
result.read("!B") # Type Float
227-
length = result.readDouble()
228-
links.append((approachedLane, hasPrio, isOpen, hasFoe,
229-
approachedInternal, state, direction, length))
230-
return tuple(links)
231-
232-
233208
def _readJunctionFoes(result):
234209
result.read("!Bi")
235210
nbJunctionFoes = result.readInt()
@@ -265,7 +240,7 @@ def _readJunctionFoes(result):
265240
tc.VAR_NEIGHBORS: _readNeighbors,
266241
tc.VAR_NEXT_TLS: _readNextTLS,
267242
tc.VAR_NEXT_STOPS: _readNextStops,
268-
tc.VAR_NEXT_LINKS: _readNextLinks,
243+
tc.VAR_NEXT_LINKS: _readLinks,
269244
tc.VAR_NEXT_STOPS2: _readStopData,
270245
tc.VAR_FOES: _readJunctionFoes,
271246
# ignore num compounds and type int

0 commit comments

Comments
 (0)