# HG changeset patch # User Mike Miller # Date 1429011864 14400 # Node ID 896fdc3697891863b6ebf87d99c3c3b247261005 # Parent 81432840e1c010cca0ba78ffa82a50b6e38863c6 Use latest Octave library API * pytave.cc, octave_to_python.cc, python_to_octave.cc: Force octave/config.h to be included before other Octave include files. Update uses of the Octave API to the latest version. Apply the following replacements: * Octave_map -> octave_map. * symbol_table::varref -> symbol_table::assign * symbol_table::global_varref -> symbol_table::global_assign * Array -> octave_value_list * Array -> string_vector * do_octave_atexit -> clean_up_and_exit diff -r 81432840e1c0 -r 896fdc369789 octave_to_python.cc --- a/octave_to_python.cc Tue Apr 14 07:32:19 2015 -0400 +++ b/octave_to_python.cc Tue Apr 14 07:44:24 2015 -0400 @@ -28,8 +28,8 @@ #undef HAVE_STAT #undef HAVE_FSTAT +#include #include -#include #include #include @@ -282,7 +282,7 @@ } static void octmap_to_pyobject(boost::python::object &py_object, - const Octave_map& map) { + const octave_map& map) { py_object = boost::python::dict(); string_vector keys = map.keys(); diff -r 81432840e1c0 -r 896fdc369789 pytave.cc --- a/pytave.cc Tue Apr 14 07:32:19 2015 -0400 +++ b/pytave.cc Tue Apr 14 07:44:24 2015 -0400 @@ -27,6 +27,7 @@ #undef HAVE_STAT #undef HAVE_FSTAT +#include #include #include @@ -125,10 +126,10 @@ variable_name_exception::excclass))); } - string make_error_message (const Octave_map& map) { + string make_error_message (const octave_map& map) { ostringstream exceptionmsg; - string message = map.stringfield("message", ""); - string identifier = map.stringfield("identifier", ""); + string message = map(0).getfield("message").string_value(); + string identifier = map(0).getfield("identifier").string_value(); Cell stackCell = map.contents("stack"); // Trim trailing new lines @@ -137,11 +138,11 @@ if (!stackCell.is_empty() && stackCell(0).is_map()) { // The struct element is called "stack" but only contain // info about the top frame. - Octave_map stack = stackCell(0).map_value(); - string file = stack.stringfield("file", ""); - string name = stack.stringfield("name", ""); - int line = stack.intfield("line", 1); - int column = stack.intfield("column", 2); + octave_map stack = stackCell(0).map_value(); + string file = stack(0).getfield("file").string_value(); + string name = stack(0).getfield("name").string_value(); + int line = stack(0).getfield("line").int_value(); + int column = stack(0).getfield("column").int_value(); exceptionmsg << file << ":" << line << ":" << column << ": "; if (!name.empty()) @@ -315,9 +316,9 @@ pyobj_to_octvalue(val, pyobject); if (global) - symbol_table::global_varref(name) = val; + symbol_table::global_assign (name, val); else - symbol_table::varref(name) = val; + symbol_table::assign (name, val); } bool isvar(const string& name, bool global) { @@ -374,7 +375,7 @@ #endif Py_BEGIN_ALLOW_THREADS - do_octave_atexit(); + clean_up_and_exit (0); Py_END_ALLOW_THREADS #ifdef HAVE_USELOCALE diff -r 81432840e1c0 -r 896fdc369789 python_to_octave.cc --- a/python_to_octave.cc Tue Apr 14 07:32:19 2015 -0400 +++ b/python_to_octave.cc Tue Apr 14 07:44:24 2015 -0400 @@ -29,11 +29,12 @@ #undef HAVE_STAT #undef HAVE_FSTAT +#include #include #include #include -#include #include +#include #include "pytavedefs.h" #include "arrayobjectdefs.h" @@ -352,15 +353,15 @@ dim_vector dims = dim_vector(1, 1); - Array vals (length); - Array keys (length); + octave_value_list vals (length); + string_vector keys (length); // Extract all keys and convert values. Remember whether dimensions // match. for(octave_idx_type i = 0; i < length; i++) { - std::string& key = keys(i); + std::string& key = keys[i]; boost::python::tuple tuple = boost::python::extract(list[i])(); @@ -396,11 +397,11 @@ } } - Octave_map map = Octave_map(dims); + octave_map map = octave_map(dims); for(octave_idx_type i = 0; i < length; i++) { - std::string& key = keys(i); + std::string& key = keys[i]; octave_value val = vals(i); if(val.is_cell()) {