Listing named values of an enum from .xs script. [message #923437] |
Tue, 25 September 2012 19:00  |
Eclipse User |
|
|
|
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
|
|
|
|
Re: Listing named values of an enum from .xs script. - Solved [message #924556 is a reply to message #923830] |
Wed, 26 September 2012 20:11  |
Eclipse User |
|
|
|
James,
just wanted to confirm that the solution you found is pretty much the only one that would work. There is a Java object that keeps track of all values for an enumeration type, but there is no public function or field to look up its content.
Even the code that generates C constants out of an enumeration (when needed) uses $spec to find all defined enumeration constants.
|
|
|
Powered by
FUDForum. Page generated in 0.35861 seconds