Nested C class setters restored in c++out mode for Octave
Suitable casts are required so that assignment of instances of nested classes
work as the nested class is duplicated in the global namespace, eg:
struct Outer {
struct Nested {
int bar;
} bar_instance;
};
Outer.bar_instance can now be assigned to.
This commit is contained in:
parent
cf3696e8f9
commit
e95ac82651
5 changed files with 41 additions and 6 deletions
|
|
@ -23,6 +23,8 @@ void setValues(struct Outer *outer, int val) {
|
|||
outer->inside3 = &outer->inside2;
|
||||
outer->inside4[0].val = val * 4;
|
||||
}
|
||||
|
||||
int getInside1Val(struct Outer *n) { return n->inside1.val; }
|
||||
%}
|
||||
|
||||
/*
|
||||
|
|
|
|||
14
Examples/test-suite/octave/nested_structs_runme.m
Normal file
14
Examples/test-suite/octave/nested_structs_runme.m
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
nested_structs
|
||||
|
||||
named = nested_structs.Named();
|
||||
named.val = 999;
|
||||
assert(nested_structs.nestedByVal(named), 999);
|
||||
assert(nested_structs.nestedByPtr(named), 999);
|
||||
|
||||
outer = nested_structs.Outer();
|
||||
outer.inside1.val = 456;
|
||||
assert(nested_structs.getInside1Val(outer), 456);
|
||||
|
||||
outer.inside1 = named;
|
||||
assert(nested_structs.getInside1Val(outer), 999);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue