Listing named values of an enum from .xs script. [message #923437] |
Tue, 25 September 2012 23:00  |
James Lockwood Messages: 43 Registered: July 2009 |
Member |
|
|
How can I list all of the named values of a particular enum from a script?
For example If I had the following decalred in a module IMuxOptions:
metaonly enum Gpio0MuxSettings {
GPIO0_MUXVALUE_GPIO = 0, /*! GPIO (0) */
GPIO0_MUXVALUE_U0Rx = 1, /*! U0Rx (1) */
GPIO0_MUXVALUE_I2C1SCL = 8, /*! I2C1SCL (8) */
GPIO0_MUXVALUE_U1Rx = 9 /*! U1Rx (9) */
};
I want to first get the number of items in Gpio0MuxSettings, then cycle through each and extract the strings. So given an object, where I find <obj>.$category == "EnumVal", I want to determine which enum value it is bound to (in this case "Gpio0MuxSettings"), the number of possible named enumeration settings, and what these names are. The output would ideally be something like this:
The object is: gpio0.mux,
gpio0.mux is an enum of type "IMuxOptions.Gpio0MuxSettings",
There are 4 named values. They are:
GPIO0_MUXVALUE_GPIO
GPIO0_MUXVALUE_U0Rx
GPIO0_MUXVALUE_I2C1SCL
GPIO0_MUXVALUE_U1Rx
Thanks in advance. It would seem straightforward, but it is eluding me.
James Lockwood
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01754 seconds