From 6a23335f227b8e301ad723678293d0ec74e08b04 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Mon, 14 Mar 2016 12:11:05 -0700 Subject: [PATCH] handle pass by objref in serialize_call --- src/orchpylib.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/orchpylib.cc b/src/orchpylib.cc index eb0ef9b15..04d0ae6a3 100644 --- a/src/orchpylib.cc +++ b/src/orchpylib.cc @@ -251,8 +251,14 @@ PyObject* serialize_call(PyObject* self, PyObject* args) { call->set_name(name, len); if (PyList_Check(arguments)) { for (size_t i = 0, size = PyList_Size(arguments); i < size; ++i) { - Obj* arg = call->add_arg()->mutable_obj(); - serialize(PyList_GetItem(arguments, i), arg); + PyObject* element = PyList_GetItem(arguments, i); + if (PyObject_IsInstance(element, (PyObject*)&PyObjRefType)) { + ObjRef objref = ((PyObjRef*) element)->val; + call->add_arg()->set_ref(objref); + } else { + Obj* arg = call->add_arg()->mutable_obj(); + serialize(PyList_GetItem(arguments, i), arg); + } } } else { PyErr_SetString(OrchPyError, "serialize_call: second argument needs to be a list");