I've been recently playing around a lot with the output from rxgen, and am 
finding the structures it builds cumbersome and ugly - in particular when 
dealing with opaques, vectors and unions.

Take, for example, the following section of xg:

struct test {
   opaque mydata;
};
union testgroup switch (afs_int32 type) {
    case 0:
        test firstDataSet;
};

This produces the following output as standard:
struct test {
        struct mydata {
                u_int mydata_len;
                char *mydata_val;
        } mydata;
};
typedef struct test test;

struct testgroup {
        afs_int32 type;
        union {
                test firstDataSet;
        } testgroup_u;
};
typedef struct testgroup testgroup;

There's a couple of problems here. The first is that access elements of the 
opaque is very cumbersome. With 'example' being an instance of struct 
testgroup, we have:

example.testgroup_u.firstDataSet.mydata.mydata_val;

I'd like to change this so we can use

example.u.firstDataSet.mydata.val

by removing the name of the structure in the union declaration, and in the len 
and val attributes of any vector.

The second problem is that in the 'test' example above, the name of the element 
(in this case mydata) has also been used to name the structure. This means that 
every opaque is tied to the name it was called in a particular structure - you 
can't copy opaques between structures without explicit, ugly, casts. I'd like 
to proposed that we use the same approach as Heimdal, and actually define ...

struct rxgen_opaque {
    u_int len;
    char * val;
}

... and use this in the XDR whenever opaques are required.

I know that these changes aren't backwards compatible, and may break 
out-of-tree users, so I'm proposing that they're only done if a new flag is 
supplied to rxgen - I'm considering using '-b' (for "brief")

Comments?

Simon._______________________________________________
OpenAFS-devel mailing list
[email protected]
https://lists.openafs.org/mailman/listinfo/openafs-devel

Reply via email to