]> git.proxmox.com Git - mirror_qemu.git/commit
qapi: allow override of default enum prefix naming
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 26 Aug 2015 13:21:20 +0000 (14:21 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 15 Sep 2015 09:59:28 +0000 (10:59 +0100)
commit351d36e454cddc67a1675740916636a7ccbf1c4b
tree23b0d0dd79925c36ca3517070a106c4f2c910b6e
parent007e620a7576e4ce2ea6955541e87d8ae8ed32ae
qapi: allow override of default enum prefix naming

The camel_to_upper() method applies some heuristics to turn
a mixed case type name into an all-uppercase name. This is
used for example, to generate enum constant name prefixes.

The heuristics don't also generate a satisfactory name
though. eg

  { 'enum': 'QCryptoTLSCredsEndpoint',
    'data': ['client', 'server']}

Results in Q_CRYPTOTLS_CREDS_ENDPOINT_CLIENT. This has
an undesirable _ after the initial Q and is missing an
_ between the CRYPTO & TLS strings.

Rather than try to add more and more heuristics to try
to cope with this, simply allow the QAPI schema to
specify the desired enum constant prefix explicitly.

eg

  { 'enum': 'QCryptoTLSCredsEndpoint',
    'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT',
    'data': ['client', 'server']}

Now gives the QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
docs/qapi-code-gen.txt
scripts/qapi-types.py
scripts/qapi.py
tests/Makefile
tests/qapi-schema/enum-bad-prefix.err [new file with mode: 0644]
tests/qapi-schema/enum-bad-prefix.exit [new file with mode: 0644]
tests/qapi-schema/enum-bad-prefix.json [new file with mode: 0644]
tests/qapi-schema/enum-bad-prefix.out [new file with mode: 0644]
tests/qapi-schema/qapi-schema-test.json
tests/qapi-schema/qapi-schema-test.out