c96c04c5ae
Replicate changes in this commit to add_symbols() for add_symbols_c().
Setting feature:immutable is now done in Allocate:cDeclaration.
Setting hasconsttype for static const variables (or constexpr) doesn't
look possible in this situation (C code for anonymous structs) - no
valid C syntax that I can figure out.
Anonymous nested structs are necessarily read-only (and set as
immutable in Swig_nested_name_unnamed_c_structs).
From https://sourceforge.net/p/swig/bugs/793/ ...
The union variable intRep below has a named type IntRepType.
typedef struct Object {
int objtype;
union IntRepType {
double dvalue;
} intRep;
} Object;
void tester() {
/* approach (1) */
obj.intRep.dvalue = 1.23;
/* approach (2) */
union IntRepType irt;
irt.dvalue = 2.34;
obj.intRep = irt;
}
Using C code there are two approaches to setting a value in intRep. Equivalents in perl are:
my $obj = example::Object->new();
# approach (1)
$obj->{intRep}->{dvalue} = 3.45;
# approach (2)
my $irt = example::IntRepType->new();
$irt->{dvalue} = 4.56;
$obj->{intRep} = $irt;
An Object_intRep_set wrapper is generated which takes type IntRepType as desired.
However, with an anonymous union:
typedef struct Object {
int objtype;
union IntRepType {
double dvalue;
} intRep;
} Object;
intRep does not have any named type name and is anonymous. It is thus not possible to create a type outside of Object to assign to intRep.
Only approach (1) is available in C and so SWIG can only provide approach (1) via wrappers too.
There is no Object_intRep_set wrapper, intRep is immutable.
Replicate redefinition/redeclaration warning message improvements
in previous commit to nested classes.
Adding the symtab to all nodes in Swig_symbol_add() has also fixed some
warning displays with %extend 302 warnings, which were completely
missing before (extend_placement.i testcase).
This is just a simple code refactor, moving and function renaming to
remove the %extend code out of the parser into its own file now
that it isn't just used in the parser.
fixed language symbol table nested classes name separator, test added
fixed %feature "flatnested" working with %extend
fixed Swig_offset_string for empty string
added simple template to save/restore values in current scope (readability reasons)
Error checking for this combination implemented as well as correcting
Octave
Also refactor, replacing CPlusPlusOut variable with cparse_cplusplusout
for an implementation which more closely resembles cparse_cplusplus which
is also required in both .c and .cxx files.