changeset 350:e89a8a37fd8a

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.
author Colin Macdonald <cbm@m.fsf.org>
date Thu, 11 Aug 2016 10:29:18 -0700
parents 140e37e8e95a
children 040aff46e4db
files @pyobject/pyobject.m oct-py-util.cc octave_to_python.cc python_to_octave.cc
diffstat 4 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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];
     }
 }
 
--- 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 (
--- 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<std::string> (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);
   }