* [Qemu-devel] Enum String Generator
@ 2015-02-14 0:33 John Snow
2015-02-15 2:37 ` Fam Zheng
0 siblings, 1 reply; 3+ messages in thread
From: John Snow @ 2015-02-14 0:33 UTC (permalink / raw)
To: qemu-devel
Just a stupid question: We don't have a macro facility in the current
codebase that generates both an enum and string table / lookup function
simultaneously, do we?
Some things really do just wind up looking grossly inelegant in C, and
this is one of them.
--js
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Enum String Generator
2015-02-14 0:33 [Qemu-devel] Enum String Generator John Snow
@ 2015-02-15 2:37 ` Fam Zheng
2015-02-16 17:37 ` John Snow
0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2015-02-15 2:37 UTC (permalink / raw)
To: John Snow; +Cc: qemu-devel
On Fri, 02/13 19:33, John Snow wrote:
> Just a stupid question: We don't have a macro facility in the current
> codebase that generates both an enum and string table / lookup function
> simultaneously, do we?
>
> Some things really do just wind up looking grossly inelegant in C, and this
> is one of them.
>
There is in QAPI:
fam@fam-t430:~/build/last$ grep -A 4 NewImageMode_lookup qapi-types.c
const char *NewImageMode_lookup[] = {
"existing",
"absolute-paths",
NULL,
};
fam@fam-t430:~/build/last$ grep -C 10 -e NEW_IMAGE qapi-types.h
...
extern const char *NewImageMode_lookup[];
typedef enum NewImageMode
{
NEW_IMAGE_MODE_EXISTING = 0,
NEW_IMAGE_MODE_ABSOLUTE_PATHS = 1,
NEW_IMAGE_MODE_MAX = 2,
} NewImageMode;
...
Is that what you want?
Fam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Enum String Generator
2015-02-15 2:37 ` Fam Zheng
@ 2015-02-16 17:37 ` John Snow
0 siblings, 0 replies; 3+ messages in thread
From: John Snow @ 2015-02-16 17:37 UTC (permalink / raw)
To: Fam Zheng; +Cc: qemu-devel
On 02/14/2015 09:37 PM, Fam Zheng wrote:
> On Fri, 02/13 19:33, John Snow wrote:
>> Just a stupid question: We don't have a macro facility in the current
>> codebase that generates both an enum and string table / lookup function
>> simultaneously, do we?
>>
>> Some things really do just wind up looking grossly inelegant in C, and this
>> is one of them.
>>
>
> There is in QAPI:
>
> fam@fam-t430:~/build/last$ grep -A 4 NewImageMode_lookup qapi-types.c
> const char *NewImageMode_lookup[] = {
> "existing",
> "absolute-paths",
> NULL,
> };
>
> fam@fam-t430:~/build/last$ grep -C 10 -e NEW_IMAGE qapi-types.h
> ...
>
> extern const char *NewImageMode_lookup[];
> typedef enum NewImageMode
> {
> NEW_IMAGE_MODE_EXISTING = 0,
> NEW_IMAGE_MODE_ABSOLUTE_PATHS = 1,
> NEW_IMAGE_MODE_MAX = 2,
> } NewImageMode;
>
> ...
>
> Is that what you want?
>
> Fam
>
More or less; though I wasn't intending on working in QAPI (I'm inside
of qtest at the moment) and I assume people wouldn't appreciate the QAPI
clutter with qtest junk.
Was just trying to figure out the best way to add a bunch of tables to
allow some test permutations -- without it being grossly redundant.
the GLib test framework doesn't seem to allow for a test matrix /
permutations particularly well. I see cases of some 2D iterations in
existing qtests, but nobody appears to have implemented some 3D+ options
structure for iterating through combinations.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-16 17:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-14 0:33 [Qemu-devel] Enum String Generator John Snow
2015-02-15 2:37 ` Fam Zheng
2015-02-16 17:37 ` John Snow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).