Mercurial > mxe-octave
comparison 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 |
comparison
equal
deleted
inserted
replaced
4425:8c51e3a9d984 | 4426:342cc3ee5e4b |
---|---|
1 diff -uNr a/src/packfields.cc b/src/packfields.cc | 1 diff -r c570624ba1cd src/packfields.cc |
2 --- a/src/packfields.cc 2015-05-27 11:43:57.000000000 -0400 | 2 --- a/src/packfields.cc Thu Jul 20 13:15:55 2017 -0400 |
3 +++ b/src/packfields.cc 2017-07-10 14:21:37.229291149 -0400 | 3 +++ b/src/packfields.cc Thu Jul 20 13:36:57 2017 -0400 |
4 @@ -15,10 +15,11 @@ | 4 @@ -15,10 +15,15 @@ |
5 | 5 |
6 #include <octave/oct.h> | 6 #include <octave/oct.h> |
7 #include <octave/utils.h> | 7 #include <octave/utils.h> |
8 +#include <octave/interpreter.h> | 8 +#include <octave/interpreter.h> |
9 #include <octave/symtab.h> | 9 #include <octave/symtab.h> |
10 #include <octave/oct-map.h> | 10 #include <octave/oct-map.h> |
11 | 11 |
12 -DEFUN_DLD (packfields, args, , | 12 +#ifdef DEFMETHOD_DLD |
13 +DEFMETHOD_DLD (packfields, interp, args, , | 13 +DEFMETHOD_DLD (packfields, interp, args, , |
14 +#else | |
15 DEFUN_DLD (packfields, args, , | |
16 +#endif | |
14 "-*- texinfo -*-\n\ | 17 "-*- texinfo -*-\n\ |
15 @deftypefn {Loadable Function} {} packfields (@var{s_name}, @var{var1}, @var{var2}, @dots{})\n\ | 18 @deftypefn {Loadable Function} {} packfields (@var{s_name}, @var{var1}, @var{var2}, @dots{})\n\ |
16 Create struct from variables.\n\ | 19 Create struct from variables.\n\ |
17 @@ -44,6 +45,9 @@ | 20 @@ -44,6 +49,11 @@ |
18 | 21 |
19 if (nargin > 0) | 22 if (nargin > 0) |
20 { | 23 { |
24 +#ifdef DEFMETHOD_DLD | |
21 + octave::symbol_table::scope *curr_scope | 25 + octave::symbol_table::scope *curr_scope |
22 + = interp.require_current_scope ("packfields"); | 26 + = interp.require_current_scope ("packfields"); |
27 +#endif | |
23 + | 28 + |
24 std::string struct_name = args (0).string_value (); | 29 std::string struct_name = args (0).string_value (); |
25 string_vector fld_names(nargin-1); | 30 string_vector fld_names(nargin-1); |
26 octave_value_list fld_vals(nargin-1); | 31 octave_value_list fld_vals(nargin-1); |
27 @@ -64,7 +68,7 @@ | 32 @@ -64,7 +74,12 @@ |
28 if (valid_identifier (fld_name)) | 33 if (valid_identifier (fld_name)) |
29 { | 34 { |
30 fld_names(i) = fld_name; | 35 fld_names(i) = fld_name; |
31 - octave_value fld_val = symbol_table::varval (fld_name); | 36 + |
37 +#ifdef DEFMETHOD_DLD | |
32 + octave_value fld_val = curr_scope->varval (fld_name); | 38 + octave_value fld_val = curr_scope->varval (fld_name); |
39 +#else | |
40 octave_value fld_val = symbol_table::varval (fld_name); | |
41 +#endif | |
33 if (fld_val.is_defined ()) | 42 if (fld_val.is_defined ()) |
34 fld_vals(i) = fld_val; | 43 fld_vals(i) = fld_val; |
35 else | 44 else |
36 @@ -77,7 +81,7 @@ | 45 @@ -77,8 +92,11 @@ |
37 if (! error_state) | 46 if (! error_state) |
38 { | 47 { |
39 // Force the symbol to be inserted in caller's scope. | 48 // Force the symbol to be inserted in caller's scope. |
40 - symbol_table::symbol_record& rec = symbol_table::insert (struct_name); | 49 +#ifdef DEFMETHOD_DLD |
41 + octave::symbol_table::symbol_record& rec = curr_scope->insert (struct_name); | 50 + octave::symbol_table::symbol_record& rec = curr_scope->insert (struct_name); |
42 | 51 +#else |
52 symbol_table::symbol_record& rec = symbol_table::insert (struct_name); | |
53 - | |
54 +#endif | |
43 octave_value& struct_ref = rec.varref (); | 55 octave_value& struct_ref = rec.varref (); |
44 | 56 |
45 diff -uNr a/src/unpackfields.cc b/src/unpackfields.cc | 57 // If not defined, use struct (). |
46 --- a/src/unpackfields.cc 2015-05-27 11:43:57.000000000 -0400 | 58 diff -r c570624ba1cd src/unpackfields.cc |
47 +++ b/src/unpackfields.cc 2017-07-10 14:21:30.893590654 -0400 | 59 --- a/src/unpackfields.cc Thu Jul 20 13:15:55 2017 -0400 |
48 @@ -15,10 +15,11 @@ | 60 +++ b/src/unpackfields.cc Thu Jul 20 13:36:57 2017 -0400 |
61 @@ -15,10 +15,15 @@ | |
49 | 62 |
50 #include <octave/oct.h> | 63 #include <octave/oct.h> |
51 #include <octave/utils.h> | 64 #include <octave/utils.h> |
52 +#include <octave/interpreter.h> | 65 +#include <octave/interpreter.h> |
53 #include <octave/symtab.h> | 66 #include <octave/symtab.h> |
54 #include <octave/oct-map.h> | 67 #include <octave/oct-map.h> |
55 | 68 |
56 -DEFUN_DLD (unpackfields, args, , | 69 +#ifdef DEFMETHOD_DLD |
57 +DEFMETHOD_DLD (unpackfields, interp, args, , | 70 +DEFMETHOD_DLD (packfields, interp, args, , |
71 +#else | |
72 DEFUN_DLD (unpackfields, args, , | |
73 +#endif | |
58 "-*- texinfo -*-\n\ | 74 "-*- texinfo -*-\n\ |
59 @deftypefn {Loadable Function} {} unpackfields (@var{s_name}, @var{fld1}, @var{fld2}, @dots{})\n\ | 75 @deftypefn {Loadable Function} {} unpackfields (@var{s_name}, @var{fld1}, @var{fld2}, @dots{})\n\ |
60 Create variables from fields of a struct.\n\ | 76 Create variables from fields of a struct.\n\ |
61 @@ -50,6 +51,9 @@ | 77 @@ -50,6 +55,11 @@ |
62 | 78 |
63 if (nargin > 0) | 79 if (nargin > 0) |
64 { | 80 { |
81 +#ifdef DEFMETHOD_DLD | |
65 + octave::symbol_table::scope *curr_scope | 82 + octave::symbol_table::scope *curr_scope |
66 + = interp.require_current_scope ("unpackfields"); | 83 + = interp.require_current_scope ("unpackfields"); |
84 +#endif | |
67 + | 85 + |
68 std::string struct_name = args (0).string_value (); | 86 std::string struct_name = args (0).string_value (); |
69 string_vector fld_names(nargin-1); | 87 string_vector fld_names(nargin-1); |
70 | 88 |
71 @@ -75,7 +79,7 @@ | 89 @@ -75,8 +85,11 @@ |
72 if (! error_state) | 90 if (! error_state) |
73 { | 91 { |
74 // Force the symbol to be inserted in caller's scope. | 92 // Force the symbol to be inserted in caller's scope. |
75 - octave_value struct_val = symbol_table::varval (struct_name); | 93 +#ifdef DEFMETHOD_DLD |
76 + octave_value struct_val = curr_scope->varval (struct_name); | 94 + octave_value struct_val = curr_scope->varval (struct_name); |
77 | 95 +#else |
96 octave_value struct_val = symbol_table::varval (struct_name); | |
97 - | |
98 +#endif | |
78 if (struct_val.is_map ()) | 99 if (struct_val.is_map ()) |
79 { | 100 { |
80 @@ -89,7 +93,7 @@ | 101 // Fast code for a built-in struct. |
102 @@ -89,7 +102,11 @@ | |
81 { | 103 { |
82 octave_scalar_map::const_iterator iter = map.seek (fld_names(i)); | 104 octave_scalar_map::const_iterator iter = map.seek (fld_names(i)); |
83 if (iter != map.end ()) | 105 if (iter != map.end ()) |
84 - symbol_table::assign (fld_names(i), map.contents (iter)); | 106 +#ifdef DEFMETHOD_DLD |
85 + curr_scope->assign (fld_names(i), map.contents (iter)); | 107 + curr_scope->assign (fld_names(i), map.contents (iter)); |
108 +#else | |
109 symbol_table::assign (fld_names(i), map.contents (iter)); | |
110 +#endif | |
86 else | 111 else |
87 { | 112 { |
88 error ("unpackfields: field %s does not exist", fld_names(i).c_str ()); | 113 error ("unpackfields: field %s does not exist", fld_names(i).c_str ()); |
89 @@ -114,7 +118,7 @@ | 114 @@ -114,7 +131,11 @@ |
90 break; | 115 break; |
91 | 116 |
92 if (val.is_defined ()) | 117 if (val.is_defined ()) |
93 - symbol_table::assign (fld_names(i), val); | 118 +#ifdef DEFMETHOD_DLD |
94 + curr_scope->assign (fld_names(i), val); | 119 + curr_scope->assign (fld_names(i), val); |
120 +#else | |
121 symbol_table::assign (fld_names(i), val); | |
122 +#endif | |
95 } | 123 } |
96 } | 124 } |
97 } | 125 } |