annotate src/of-general-1-symtab-fixes.patch @ 4426:342cc3ee5e4b

of-general: update patch to work for both stable and dev octave * src/of-general-1-symtab-fixes.patch: updated patch
author John D
date Fri, 21 Jul 2017 12:05:46 -0400
parents 60b45297db4a
children 5e3fb4c40644
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
1 diff -r c570624ba1cd src/packfields.cc
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
2 --- a/src/packfields.cc Thu Jul 20 13:15:55 2017 -0400
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
3 +++ b/src/packfields.cc Thu Jul 20 13:36:57 2017 -0400
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
4 @@ -15,10 +15,15 @@
4409
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
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
12 +#ifdef DEFMETHOD_DLD
4409
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, ,
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
14 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
15 DEFUN_DLD (packfields, args, ,
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
16 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 "-*- texinfo -*-\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 @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
19 Create struct from variables.\n\
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
20 @@ -44,6 +49,11 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 if (nargin > 0)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 {
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
24 +#ifdef DEFMETHOD_DLD
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 + octave::symbol_table::scope *curr_scope
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
26 + = interp.require_current_scope ("packfields");
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
27 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 +
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 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
30 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
31 octave_value_list fld_vals(nargin-1);
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
32 @@ -64,7 +74,12 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 if (valid_identifier (fld_name))
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 fld_names(i) = fld_name;
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
36 +
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
37 +#ifdef DEFMETHOD_DLD
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 + octave_value fld_val = curr_scope->varval (fld_name);
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
39 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
40 octave_value fld_val = symbol_table::varval (fld_name);
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
41 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 if (fld_val.is_defined ())
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 fld_vals(i) = fld_val;
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 else
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
45 @@ -77,8 +92,11 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 if (! error_state)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 // Force the symbol to be inserted in caller's scope.
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
49 +#ifdef DEFMETHOD_DLD
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
50 + octave::symbol_table::symbol_record& rec = curr_scope->insert (struct_name);
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
51 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
52 symbol_table::symbol_record& rec = symbol_table::insert (struct_name);
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
53 -
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
54 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 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
56
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
57 // If not defined, use struct ().
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
58 diff -r c570624ba1cd src/unpackfields.cc
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
59 --- a/src/unpackfields.cc Thu Jul 20 13:15:55 2017 -0400
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
60 +++ b/src/unpackfields.cc Thu Jul 20 13:36:57 2017 -0400
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
61 @@ -15,10 +15,15 @@
4409
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 #include <octave/oct.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 #include <octave/utils.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 +#include <octave/interpreter.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 #include <octave/symtab.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 #include <octave/oct-map.h>
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
69 +#ifdef DEFMETHOD_DLD
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
70 +DEFMETHOD_DLD (packfields, interp, args, ,
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
71 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
72 DEFUN_DLD (unpackfields, args, ,
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
73 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 "-*- texinfo -*-\n\
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 @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
76 Create variables from fields of a struct.\n\
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
77 @@ -50,6 +55,11 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 if (nargin > 0)
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 {
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
81 +#ifdef DEFMETHOD_DLD
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 + octave::symbol_table::scope *curr_scope
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
83 + = interp.require_current_scope ("unpackfields");
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
84 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 +
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 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
87 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
88
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
89 @@ -75,8 +85,11 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 if (! error_state)
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 // Force the symbol to be inserted in caller's scope.
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
93 +#ifdef DEFMETHOD_DLD
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 + octave_value struct_val = curr_scope->varval (struct_name);
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
95 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
96 octave_value struct_val = symbol_table::varval (struct_name);
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
97 -
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
98 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 if (struct_val.is_map ())
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 {
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
101 // Fast code for a built-in struct.
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
102 @@ -89,7 +102,11 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 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
105 if (iter != map.end ())
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
106 +#ifdef DEFMETHOD_DLD
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 + curr_scope->assign (fld_names(i), map.contents (iter));
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
108 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
109 symbol_table::assign (fld_names(i), map.contents (iter));
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
110 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 else
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 {
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 error ("unpackfields: field %s does not exist", fld_names(i).c_str ());
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
114 @@ -114,7 +131,11 @@
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 break;
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 if (val.is_defined ())
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
118 +#ifdef DEFMETHOD_DLD
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 + curr_scope->assign (fld_names(i), val);
4426
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
120 +#else
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
121 symbol_table::assign (fld_names(i), val);
342cc3ee5e4b of-general: update patch to work for both stable and dev octave
John D
parents: 4409
diff changeset
122 +#endif
4409
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 }
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 }
60b45297db4a allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 }