# HG changeset patch # User Colin Macdonald # Date 1470936558 25200 # Node ID e89a8a37fd8a1f841d1eda3853a54a1d0fd9ea2c # Parent 140e37e8e95a394220fb2a3af60f57128ab5b981 Rename the Octave-Python communication dict * @pyobject/pyobject.m: Rename dict. * octave_to_python.cc: Rename dict. * pytave_utils.cc: Rename dict. * python_to_octave.cc: Rename dict. diff -r 140e37e8e95a -r e89a8a37fd8a @pyobject/pyobject.m --- a/@pyobject/pyobject.m Thu Aug 11 10:15:26 2016 -0700 +++ b/@pyobject/pyobject.m Thu Aug 11 10:29:18 2016 -0700 @@ -45,15 +45,15 @@ if (isa (x, "pyobject")) obj = x; else - ## Ensure _InOctave dict exists - cmd = [ "if not getattr(__import__('__main__'), '_InOctave', None):\n" ... - " __import__('__main__')._InOctave = dict()" ]; + ## Ensure dict for Octave communication exists + cmd = [ "if not getattr(__import__('__main__'), '_in_octave', None):\n" ... + " __import__('__main__')._in_octave = dict()" ]; pyexec (cmd); ## Function to insert and return the hex id cmd = [ "def _in_octave_insert(x):\n" ... " h = hex(id(x))\n" ... - " __import__('__main__')._InOctave[h] = x\n" ... + " __import__('__main__')._in_octave[h] = x\n" ... " return h" ]; pyexec (cmd); @@ -67,7 +67,7 @@ ## The actual constructor. Nicer to split this off to static method ## like `pyobject.new` but I don't know how to call from pycall.cc. ## Warning: not intended for casual use: you must also insert the - ## object into the Python `_InOctave` dict with key `id`. + ## object into the Python `_in_octave` dict with key `id`. obj.id = id; return endif @@ -93,8 +93,8 @@ #disp ("delete") - # throws KeyError if it wasn't in there for some reason - cmd = sprintf ("__import__('__main__')._InOctave.pop('%s')", x.id); + ## throws KeyError if it wasn't in there for some reason + cmd = sprintf ("__import__('__main__')._in_octave.pop('%s')", x.id); pyexec (cmd) endfunction diff -r 140e37e8e95a -r e89a8a37fd8a oct-py-util.cc --- a/oct-py-util.cc Thu Aug 11 10:15:26 2016 -0700 +++ b/oct-py-util.cc Thu Aug 11 10:29:18 2016 -0700 @@ -92,7 +92,7 @@ { octave_value_list tmp = feval ("getid", ovl (oct_value), 1); std::string hexid = tmp(0).string_value (); - py_object = main_module.attr ("_InOctave")[hexid]; + py_object = main_module.attr ("_in_octave")[hexid]; } } diff -r 140e37e8e95a -r e89a8a37fd8a octave_to_python.cc --- a/octave_to_python.cc Thu Aug 11 10:15:26 2016 -0700 +++ b/octave_to_python.cc Thu Aug 11 10:29:18 2016 -0700 @@ -190,7 +190,7 @@ { octave_value_list tmp = feval ("getid", ovl (octvalue), 1); std::string hexid = tmp(0).string_value (); - py_object = boost::python::import ("__main__").attr ("_InOctave")[hexid]; + py_object = boost::python::import ("__main__").attr ("_in_octave")[hexid]; } else throw value_convert_exception ( diff -r 140e37e8e95a -r e89a8a37fd8a python_to_octave.cc --- a/python_to_octave.cc Thu Aug 11 10:15:26 2016 -0700 +++ b/python_to_octave.cc Thu Aug 11 10:29:18 2016 -0700 @@ -322,11 +322,11 @@ object idtmp = hex_function (id_function (py_object)); std::string id = extract (idtmp); - // Ensure _InOctave dict exists - if (! PyObject_HasAttrString (main_module.ptr (), "_InOctave")) - main_module.attr ("_InOctave") = boost::python::dict (); + // Ensure dict for Octave communication exists + if (! PyObject_HasAttrString (main_module.ptr (), "_in_octave")) + main_module.attr ("_in_octave") = boost::python::dict (); - main_module.attr ("_InOctave")[id] = py_object; + main_module.attr ("_in_octave")[id] = py_object; // Create @pyobject oct_value = feval ("pyobject", ovl (0, id), 2); }