Mercurial > mxe-octave
annotate src/of-general-1-symtab-fixes.patch @ 4692:3f120419c40d
* src/of-general-1-symtab-fixes.patch: fix unpackfields name in patch
author | John Donoghue |
---|---|
date | Thu, 03 May 2018 10:25:23 -0400 |
parents | 5e3fb4c40644 |
children |
rev | line source |
---|---|
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
1 diff -uNr a/src/packfields.cc b/src/packfields.cc |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
2 --- a/src/packfields.cc 2015-05-27 11:43:57.000000000 -0400 |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
3 +++ b/src/packfields.cc 2017-12-07 15:09:12.838253308 -0500 |
4426
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 |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
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 |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
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 |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
45 @@ -76,46 +91,27 @@ |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
46 |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 if (! error_state) |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 { |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
49 - // Force the symbol to be inserted in caller's scope. |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
50 - symbol_table::symbol_record& rec = symbol_table::insert (struct_name); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
51 - |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
52 - octave_value& struct_ref = rec.varref (); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
53 - |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
54 - // If not defined, use struct (). |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
55 - if (! struct_ref.is_defined ()) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
56 - struct_ref = octave_scalar_map (); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
57 - |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
58 - if (struct_ref.is_map ()) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
59 - { |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
60 - // Fast code for a built-in struct. |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
61 - octave_scalar_map map = struct_ref.scalar_map_value (); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
62 - |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
63 - if (! error_state) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
64 - { |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
65 - // Do the actual work. |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
66 - struct_ref = octave_value (); // Unshare map. |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
67 - for (octave_idx_type i = 0; i < nargin-1; i++) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
68 - map.assign (fld_names(i), fld_vals(i)); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
69 - struct_ref = map; |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
70 - } |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
71 - else |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
72 - error ("packfields: structure must have singleton dimensions"); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
73 - } |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
74 - else |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
75 - { |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
76 - // General case. |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
77 - struct_ref.make_unique (); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
78 - std::list<octave_value_list> idx (1); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
79 - |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
80 - for (octave_idx_type i = 0; i < nargin-1; i++) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
81 - { |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
82 - idx.front () = args(i+1); // Save one string->octave_value conversion. |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
83 - struct_ref = struct_ref.subsasgn (".", idx, fld_vals (i)); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
84 - |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
85 - if (error_state) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
86 - break; |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
87 - } |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
88 - } |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
89 +#ifdef DEFMETHOD_DLD |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
90 + 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
|
91 +#else |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
92 + octave_value struct_val = symbol_table::varval (struct_name); |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
93 +#endif |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
94 + |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
95 + octave_scalar_map map; |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
96 + |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
97 + if (struct_val.is_defined () && struct_val.is_map ()) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
98 + map = struct_val.scalar_map_value (); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
99 + |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
100 + for (octave_idx_type i = 0; i < nargin-1; i++) |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
101 + map.assign (fld_names(i), fld_vals(i)); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
102 + |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
103 + struct_val = map; |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
104 + |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
105 +#ifdef DEFMETHOD_DLD |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
106 + curr_scope.assign (struct_name, struct_val); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
107 +#else |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
108 + symbol_table::assign (struct_name, struct_val); |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
109 +#endif |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
110 } |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
111 } |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
112 else |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
113 diff -uNr a/src/unpackfields.cc b/src/unpackfields.cc |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
114 --- a/src/unpackfields.cc 2015-05-27 11:43:57.000000000 -0400 |
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
115 +++ b/src/unpackfields.cc 2017-12-07 15:09:12.842253124 -0500 |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
116 @@ -15,10 +15,15 @@ |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 #include <octave/oct.h> |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 #include <octave/utils.h> |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 +#include <octave/interpreter.h> |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 #include <octave/symtab.h> |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 #include <octave/oct-map.h> |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
124 +#ifdef DEFMETHOD_DLD |
4692
3f120419c40d
* src/of-general-1-symtab-fixes.patch: fix unpackfields name in patch
John Donoghue
parents:
4579
diff
changeset
|
125 +DEFMETHOD_DLD (unpackfields, interp, args, , |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
126 +#else |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
127 DEFUN_DLD (unpackfields, args, , |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
128 +#endif |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 "-*- texinfo -*-\n\ |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 @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
|
131 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
|
132 @@ -50,6 +55,11 @@ |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 if (nargin > 0) |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 { |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
136 +#ifdef DEFMETHOD_DLD |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
137 + 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
|
138 + = interp.require_current_scope ("unpackfields"); |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
139 +#endif |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 + |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 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
|
142 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
|
143 |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
144 @@ -75,8 +85,11 @@ |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 if (! error_state) |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 { |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 // 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
|
148 +#ifdef DEFMETHOD_DLD |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
149 + 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
|
150 +#else |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
151 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
|
152 - |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
153 +#endif |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 if (struct_val.is_map ()) |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 { |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
156 // 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
|
157 @@ -89,7 +102,11 @@ |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 { |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 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
|
160 if (iter != map.end ()) |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
161 +#ifdef DEFMETHOD_DLD |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
162 + 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
|
163 +#else |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
164 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
|
165 +#endif |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 else |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 { |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 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
|
169 @@ -114,7 +131,11 @@ |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 break; |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 if (val.is_defined ()) |
4426
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
173 +#ifdef DEFMETHOD_DLD |
4579
5e3fb4c40644
* of-general-1-symtab-fixes.patch: Update for Octave changes.
John W. Eaton <jwe@octave.org>
parents:
4426
diff
changeset
|
174 + 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
|
175 +#else |
342cc3ee5e4b
of-general: update patch to work for both stable and dev octave
John D
parents:
4409
diff
changeset
|
176 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
|
177 +#endif |
4409
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 } |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 } |
60b45297db4a
allow of-general to build with current octave sources
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 } |