Extra info from Andrea's email about this to swig-user:
I noticed an unexpected behaviour in the generation of the XML wrapper
code of nested structs. It seems that the declaration of the nested
struct comes *after* the declaration of the container struct.
But it seems that the generated XML wrapper code doesn't reflect the
situation above. In fact, the definition of my_struct_nested comes
*after* the definition of my_struct.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
However, we don't really define what the generated XML looks like - AFAICS we just say:
The XML is a dump of SWIG's internal parse tree and as such it is subject to change at any time as and when SWIG's implementation changes.
Therefore I'm not sure that the relative order of things in the XML should be expected to reflect declaration order. We're really just dumping SWIG's internal data structure as XML and the data structure in memory isn't ordered in this way.
I think consumers probably need to read all the data and build up a structure from it, then use that to resolve cases such as this.
Also pragmatically this was been open for approaching 17 years without anyone caring enough to try to enforce the requested ordering, so realistically it's unlikely that's going to happen. So I'm closing as "wont-fix".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
interface file and xml generated wrapper
Extra info from Andrea's email about this to swig-user:
I noticed an unexpected behaviour in the generation of the XML wrapper
code of nested structs. It seems that the declaration of the nested
struct comes *after* the declaration of the container struct.
E.g.
typedef struct {
struct {
char a;
} nested;
} my_struct;
Looking at SWIG documentation I understand that the example below should
be transformed in something like:
typedef struct {
char a;
} my_struct_nested;
typedef struct {
my_struct_nested nested;
} my_struct;
But it seems that the generated XML wrapper code doesn't reflect the
situation above. In fact, the definition of my_struct_nested comes
*after* the definition of my_struct.
Still seems to be the case with current git master.
@wsfulton Did your recent nested class change to
-xmladdress this too?It seems not.
However, we don't really define what the generated XML looks like - AFAICS we just say:
Therefore I'm not sure that the relative order of things in the XML should be expected to reflect declaration order. We're really just dumping SWIG's internal data structure as XML and the data structure in memory isn't ordered in this way.
I think consumers probably need to read all the data and build up a structure from it, then use that to resolve cases such as this.
Also pragmatically this was been open for approaching 17 years without anyone caring enough to try to enforce the requested ordering, so realistically it's unlikely that's going to happen. So I'm closing as "wont-fix".