Re: [PATCH v2 11/16] scripts/qapi: pull c_name from camel_to_upper to caller

Paolo Bonzini
2026-03-31T07:34:15Z

On 2/25/26 09:32, Markus Armbruster wrote:
> { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
>
> This tests a downstream extension prefix __RFQDN_.
>
> As is, we generate
>
> typedef enum __org_qemu_x_Enum {
> ORG_QEMU_X_ENUM___ORG_QEMU_X_VALUE,
> ORG_QEMU_X_ENUM__MAX,
> } __org_qemu_x_Enum;
>
> Without the .lstrip('_'), we'd generate
>
> typedef enum __org_qemu_x_Enum {
> __ORG_QEMU_X_ENUM___ORG_QEMU_X_VALUE,
> __ORG_QEMU_X_ENUM__MAX,
> } __org_qemu_x_Enum;
>
> Meh.
>
> Turns out this isn't on purpose. Back then, the loop to map camel to
> upper worked differently, and produced unwanted leading '_'. For
> instance, it mapped 'AbraCadabra' to '_ABRA_CADABRA'. The .lstrip()
> made the function produce 'ABRA_CADABRA'. It also makes it eat
> downstream extensions' leading '__'. Oopsie.

Which would be a reserved C identifier, wouldn't it? So it seems it
still has its merit, after all (but it is limited to C).

Paolo