L. Mihalkovic wrote:
I am
trying to map the Carbon HIViewImageContentInfo struct for SWT (yes, I
did figure how to declare a struct that contains a union by looking at
other examples): as far as I can tell by looking at the C generated the
union capability is actually lost (the ability to choose at runtime
which field I want to set).
I looked at pretty much all the other carbon structures that contain
unions, and in all cases, the SWT code has made a choice of using only
one of the members of the union via
for example:
struct DataBrowserAccessibilityItemInfo {
/*
* A UInt32 which identifies how to interpret the following union.
* Set this field to zero if you fill out the union's data in the
* form of a DataBrowserAccessibilityItemInfoV0 structure. Set this
* field to one if you fill out the union's data in the form of a
* DataBrowserAccessibilityItemInfoV1 structure.
*/
UInt32 version;
union {
DataBrowserAccessibilityItemInfoV0 v0;
DataBrowserAccessibilityItemInfoV1 v1;
} u;
};
The mapping only provides access via v0 and access via the v1
definition is lost. what if I want to be able to do
browserInfo.u.v1.xxxx = ssss
Am I missing something obvious?! (for now I did the same and mapped
only one of the fields knowing that the actual values would endup
looking right to Mac OS, but that does not strike me a legible code).
allo... anyone?
simply put can I do:
DataBrowserAccessibilityItemInfo XX;
XX.u.v0.aaaa = ....
AND
XX.u.v1.zzzz = ....
via some syntax in JNIGenerator. my impression so far is that I can do
one OR the other but not keep the real union behavior.
--
Laurent Mihalkovic, co-author SWT/JFace in Action (www.manning.com/scarpino)
|