annotate src/of-general-1-symtab-fixes.patch @ 4409:60b45297db4a

allow of-general to build with current octave sources * src/of-general-1-symtab-fixes.patch: New file. * dist-files.mk: Update.
author John W. Eaton <jwe@octave.org>
date Mon, 10 Jul 2017 14:31:09 -0400
parents
children 342cc3ee5e4b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 diff -uNr a/src/packfields.cc b/src/packfields.cc
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 --- a/src/packfields.cc 2015-05-27 11:43:57.000000000 -0400
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 +++ b/src/packfields.cc 2017-07-10 14:21:37.229291149 -0400
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 @@ -15,10 +15,11 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 #include <octave/oct.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 #include <octave/utils.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 +#include <octave/interpreter.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 #include <octave/symtab.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 #include <octave/oct-map.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 -DEFUN_DLD (packfields, args, ,
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 +DEFMETHOD_DLD (packfields, interp, args, ,
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 "-*- texinfo -*-\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 @deftypefn {Loadable Function} {} packfields (@var{s_name}, @var{var1}, @var{var2}, @dots{})\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 Create struct from variables.\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 @@ -44,6 +45,9 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 if (nargin > 0)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 + octave::symbol_table::scope *curr_scope
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 + = interp.require_current_scope ("packfields");
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 +
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 std::string struct_name = args (0).string_value ();
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 string_vector fld_names(nargin-1);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 octave_value_list fld_vals(nargin-1);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 @@ -64,7 +68,7 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 if (valid_identifier (fld_name))
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 fld_names(i) = fld_name;
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 - octave_value fld_val = symbol_table::varval (fld_name);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 + octave_value fld_val = curr_scope->varval (fld_name);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 if (fld_val.is_defined ())
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 fld_vals(i) = fld_val;
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 else
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 @@ -77,7 +81,7 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 if (! error_state)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 // Force the symbol to be inserted in caller's scope.
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 - symbol_table::symbol_record& rec = symbol_table::insert (struct_name);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 + octave::symbol_table::symbol_record& rec = curr_scope->insert (struct_name);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 octave_value& struct_ref = rec.varref ();
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 diff -uNr a/src/unpackfields.cc b/src/unpackfields.cc
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 --- a/src/unpackfields.cc 2015-05-27 11:43:57.000000000 -0400
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 +++ b/src/unpackfields.cc 2017-07-10 14:21:30.893590654 -0400
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 @@ -15,10 +15,11 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 #include <octave/oct.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include <octave/utils.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 +#include <octave/interpreter.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 #include <octave/symtab.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 #include <octave/oct-map.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 -DEFUN_DLD (unpackfields, args, ,
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 +DEFMETHOD_DLD (unpackfields, interp, args, ,
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 "-*- texinfo -*-\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 @deftypefn {Loadable Function} {} unpackfields (@var{s_name}, @var{fld1}, @var{fld2}, @dots{})\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 Create variables from fields of a struct.\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 @@ -50,6 +51,9 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 if (nargin > 0)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 + octave::symbol_table::scope *curr_scope
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 + = interp.require_current_scope ("unpackfields");
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 +
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 std::string struct_name = args (0).string_value ();
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 string_vector fld_names(nargin-1);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 @@ -75,7 +79,7 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 if (! error_state)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 // Force the symbol to be inserted in caller's scope.
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 - octave_value struct_val = symbol_table::varval (struct_name);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 + octave_value struct_val = curr_scope->varval (struct_name);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 if (struct_val.is_map ())
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 @@ -89,7 +93,7 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 octave_scalar_map::const_iterator iter = map.seek (fld_names(i));
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 if (iter != map.end ())
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 - symbol_table::assign (fld_names(i), map.contents (iter));
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 + curr_scope->assign (fld_names(i), map.contents (iter));
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 else
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 error ("unpackfields: field %s does not exist", fld_names(i).c_str ());
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 @@ -114,7 +118,7 @@
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 break;
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 if (val.is_defined ())
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 - symbol_table::assign (fld_names(i), val);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 + curr_scope->assign (fld_names(i), val);
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 }
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 }
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 }