Mercurial > pytave
comparison python_to_octave.cc @ 347:7f039ffe501b
Store the _InOctave dict only in main
* @pyobject/pyobject.m: Simplified _InOctave storage.
* octave_to_python.cc: Rename _InOctave dict.
* pytave_utils.cc: Rename _InOctave dict.
* python_to_octave.cc: Simplified _InOctave storage.
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Wed, 10 Aug 2016 11:34:19 -0700 |
parents | 06b8aeea456f |
children | d4744d829ee0 |
comparison
equal
deleted
inserted
replaced
346:b1eff49bd139 | 347:7f039ffe501b |
---|---|
321 object hex_function = builtins_module.attr ("hex"); | 321 object hex_function = builtins_module.attr ("hex"); |
322 object id_function = builtins_module.attr ("id"); | 322 object id_function = builtins_module.attr ("id"); |
323 object idtmp = hex_function (id_function (py_object)); | 323 object idtmp = hex_function (id_function (py_object)); |
324 std::string id = extract<std::string> (idtmp); | 324 std::string id = extract<std::string> (idtmp); |
325 | 325 |
326 // Ensure we have a __InOct__ dict, and then put `res` into it | 326 // Ensure _InOctave dict exists |
327 exec ("if not (\"__InOct__\" in vars() or \"__InOct__\" in globals()):\n" | 327 // TODO: don't need exec, just do here in C |
328 " __InOct__ = dict()\n" | 328 exec ("if not getattr(__import__('__main__'), '_InOctave', None):\n" |
329 " # FIXME: make it accessible elsewhere?\n" | 329 " __import__('__main__')._InOctave = dict()", |
330 " import __main__\n" | |
331 " __main__.__InOct__ = __InOct__\n", | |
332 main_namespace, main_namespace); | 330 main_namespace, main_namespace); |
333 main_namespace["__InOct__"][id] = py_object; | 331 |
332 main_namespace["_InOctave"][id] = py_object; | |
334 // Create @pyobject | 333 // Create @pyobject |
335 oct_value = feval ("pyobject", ovl (0, id), 2); | 334 oct_value = feval ("pyobject", ovl (0, id), 2); |
336 } | 335 } |
337 | 336 |
338 void pyobj_to_octvalue (octave_value& oct_value, | 337 void pyobj_to_octvalue (octave_value& oct_value, |