camel_to_upper() converts its argument from camel case to upper case
with '_' between words.  Used for generated enumeration constant
prefixes.
When some of the words are spelled all caps, where exactly to insert
'_' is guesswork.  camel_to_upper()'s guesses are bad enough in places
to make people override them with a 'prefix' in the schema.
Rewrite it to guess better:
1. Insert '_' after a non-upper case character followed by an upper
   case character:
       OneTwo -> ONE_TWO
       One2Three -> ONE2_THREE
2. Insert '_' before the last upper case character followed by a
   non-upper case character:
       ACRONYMWord -> ACRONYM_Word
   Except at the beginning (as in OneTwo above), or when there is
   already one:
       AbCd -> AB_CD
This changes the default enumeration constant prefix for a number of
enums.  Generated enumeration constants change only where the default
is not overridden with 'prefix'.
The following enumerations without a 'prefix' change:
    enum                            old camel_to_upper()
                                    new camel_to_upper()
    ------------------------------------------------------------------
    DisplayGLMode                   DISPLAYGL_MODE
                                    DISPLAY_GL_MODE
    EbpfProgramID                   EBPF_PROGRAMID
                                    EBPF_PROGRAM_ID
    HmatLBDataType                  HMATLB_DATA_TYPE
                                    HMAT_LB_DATA_TYPE
    HmatLBMemoryHierarchy           HMATLB_MEMORY_HIERARCHY
                                    HMAT_LB_MEMORY_HIERARCHY
    MultiFDCompression              MULTIFD_COMPRESSION
                                    MULTI_FD_COMPRESSION
    OffAutoPCIBAR                   OFF_AUTOPCIBAR
                                    OFF_AUTO_PCIBAR
    QCryptoBlockFormat              Q_CRYPTO_BLOCK_FORMAT
                                    QCRYPTO_BLOCK_FORMAT
    QCryptoBlockLUKSKeyslotState    Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE
                                    QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE
    QKeyCode                        Q_KEY_CODE
                                    QKEY_CODE
    XDbgBlockGraphNodeType          X_DBG_BLOCK_GRAPH_NODE_TYPE
                                    XDBG_BLOCK_GRAPH_NODE_TYPE
    TestUnionEnumA                  TEST_UNION_ENUMA
                                    TEST_UNION_ENUM_A
Add a 'prefix' so generated code doesn't change now.  Subsequent
commits will remove most of them again.  Two will remain:
MULTIFD_COMPRESSION, because migration code generally spells "multifd"
that way, and Q_KEY_CODE, because that one is baked into
subprojects/keycodemapdb/tools/keymap-gen.
The following enumerations with a 'prefix' change so that the prefix
is now superfluous:
    enum                            old camel_to_upper()
                                    new camel_to_upper() [equal to prefix]
    ------------------------------------------------------------------
    BlkdebugIOType                  BLKDEBUGIO_TYPE
                                    BLKDEBUG_IO_TYPE
    QCryptoTLSCredsEndpoint         Q_CRYPTOTLS_CREDS_ENDPOINT
                                    QCRYPTO_TLS_CREDS_ENDPOINT
    QCryptoSecretFormat             Q_CRYPTO_SECRET_FORMAT
                                    QCRYPTO_SECRET_FORMAT
    QCryptoCipherMode               Q_CRYPTO_CIPHER_MODE
                                    QCRYPTO_CIPHER_MODE
    QCryptodevBackendType           Q_CRYPTODEV_BACKEND_TYPE
                                    QCRYPTODEV_BACKEND_TYPE
    QType [builtin]                 Q_TYPE
                                    QTYPE
Drop these prefixes.
The following enumerations with a 'prefix' change without making the
'prefix' superfluous:
    enum                            old camel_to_upper()
                                    new camel_to_upper() [equal to prefix]
                                    prefix
    ------------------------------------------------------------------
    CpuS390Entitlement              CPUS390_ENTITLEMENT
                                    CPU_S390_ENTITLEMENT
                                    S390_CPU_ENTITLEMENT
    CpuS390Polarization             CPUS390_POLARIZATION
                                    CPU_S390_POLARIZATION
                                    S390_CPU_POLARIZATION
    CpuS390State                    CPUS390_STATE
                                    CPU_S390_STATE
                                    S390_CPU_STATE
    QAuthZListFormat                Q_AUTHZ_LIST_FORMAT
                                    QAUTH_Z_LIST_FORMAT
                                    QAUTHZ_LIST_FORMAT
    QAuthZListPolicy                Q_AUTHZ_LIST_POLICY
                                    QAUTH_Z_LIST_POLICY
                                    QAUTHZ_LIST_POLICY
    QCryptoAkCipherAlgorithm        Q_CRYPTO_AK_CIPHER_ALGORITHM
                                    QCRYPTO_AK_CIPHER_ALGORITHM
                                    QCRYPTO_AKCIPHER_ALG
    QCryptoAkCipherKeyType          Q_CRYPTO_AK_CIPHER_KEY_TYPE
                                    QCRYPTO_AK_CIPHER_KEY_TYPE
                                    QCRYPTO_AKCIPHER_KEY_TYPE
    QCryptoCipherAlgorithm          Q_CRYPTO_CIPHER_ALGORITHM
                                    QCRYPTO_CIPHER_ALGORITHM
                                    QCRYPTO_CIPHER_ALG
    QCryptoHashAlgorithm            Q_CRYPTO_HASH_ALGORITHM
                                    QCRYPTO_HASH_ALGORITHM
                                    QCRYPTO_HASH_ALG
    QCryptoIVGenAlgorithm           Q_CRYPTOIV_GEN_ALGORITHM
                                    QCRYPTO_IV_GEN_ALGORITHM
                                    QCRYPTO_IVGEN_ALG
    QCryptoRSAPaddingAlgorithm      Q_CRYPTORSA_PADDING_ALGORITHM
                                    QCRYPTO_RSA_PADDING_ALGORITHM
                                    QCRYPTO_RSA_PADDING_ALG
    QCryptodevBackendAlgType        Q_CRYPTODEV_BACKEND_ALG_TYPE
                                    QCRYPTODEV_BACKEND_ALG_TYPE
                                    QCRYPTODEV_BACKEND_ALG
    QCryptodevBackendServiceType    Q_CRYPTODEV_BACKEND_SERVICE_TYPE
                                    QCRYPTODEV_BACKEND_SERVICE_TYPE
                                    QCRYPTODEV_BACKEND_SERVICE
Subsequent commits will tweak things to remove most of these prefixes.
Only QAUTHZ_LIST_FORMAT and QAUTHZ_LIST_POLICY will remain.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240904111836.3273842-2-armbru@redhat.com>
		
	
			
		
			
				
	
	
		
			223 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			223 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
module ./builtin
 | 
						|
object q_empty
 | 
						|
enum QType
 | 
						|
    member none
 | 
						|
    member qnull
 | 
						|
    member qnum
 | 
						|
    member qstring
 | 
						|
    member qdict
 | 
						|
    member qlist
 | 
						|
    member qbool
 | 
						|
module doc-good.json
 | 
						|
enum Enum
 | 
						|
    member one
 | 
						|
        if IFONE
 | 
						|
        feature enum-member-feat
 | 
						|
    member two
 | 
						|
    if IFCOND
 | 
						|
    feature enum-feat
 | 
						|
object Base
 | 
						|
    member base1: Enum optional=False
 | 
						|
    if {'all': ['IFALL1', 'IFALL2']}
 | 
						|
object Variant1
 | 
						|
    member var1: str optional=False
 | 
						|
        if IFSTR
 | 
						|
        feature member-feat
 | 
						|
    feature variant1-feat
 | 
						|
object Variant2
 | 
						|
object Object
 | 
						|
    base Base
 | 
						|
    tag base1
 | 
						|
    case one: Variant1
 | 
						|
    case two: Variant2
 | 
						|
        if {'any': ['IFONE', 'IFTWO']}
 | 
						|
    feature union-feat1
 | 
						|
alternate Alternate
 | 
						|
    tag type
 | 
						|
    case i: int
 | 
						|
    case b: bool
 | 
						|
    if {'not': {'any': ['IFONE', 'IFTWO']}}
 | 
						|
    feature alt-feat
 | 
						|
object q_obj_cmd-arg
 | 
						|
    member arg1: int optional=False
 | 
						|
    member arg2: str optional=True
 | 
						|
    member arg3: bool optional=False
 | 
						|
command cmd q_obj_cmd-arg -> Object
 | 
						|
    gen=True success_response=True boxed=False oob=False preconfig=False
 | 
						|
    feature cmd-feat1
 | 
						|
    feature cmd-feat2
 | 
						|
command cmd-boxed Object -> None
 | 
						|
    gen=True success_response=True boxed=True oob=False preconfig=False
 | 
						|
    feature cmd-feat1
 | 
						|
    feature cmd-feat2
 | 
						|
event EVT_BOXED Object
 | 
						|
    boxed=True
 | 
						|
    feature feat3
 | 
						|
doc freeform
 | 
						|
    body=
 | 
						|
= Section
 | 
						|
doc freeform
 | 
						|
    body=
 | 
						|
== Subsection
 | 
						|
 | 
						|
*with emphasis*
 | 
						|
@var {in braces}
 | 
						|
 | 
						|
* List item one
 | 
						|
* Two, multiple
 | 
						|
  lines
 | 
						|
 | 
						|
* Three
 | 
						|
  Still in list
 | 
						|
 | 
						|
Not in list
 | 
						|
 | 
						|
- Second list
 | 
						|
  Note: still in list
 | 
						|
 | 
						|
Note: not in list
 | 
						|
 | 
						|
1. Third list
 | 
						|
   is numbered
 | 
						|
 | 
						|
2. another item
 | 
						|
 | 
						|
Returns: the King
 | 
						|
Since: the first age
 | 
						|
Notes:
 | 
						|
 | 
						|
1. Lorem ipsum dolor sit amet
 | 
						|
 | 
						|
2. Ut enim ad minim veniam
 | 
						|
 | 
						|
Duis aute irure dolor
 | 
						|
 | 
						|
Example:
 | 
						|
 | 
						|
-> in
 | 
						|
<- out
 | 
						|
Examples:
 | 
						|
- *verbatim*
 | 
						|
- {braces}
 | 
						|
doc symbol=Enum
 | 
						|
    body=
 | 
						|
 | 
						|
    arg=one
 | 
						|
The _one_ {and only}, description on the same line
 | 
						|
    arg=two
 | 
						|
 | 
						|
    feature=enum-feat
 | 
						|
Also _one_ {and only}
 | 
						|
    feature=enum-member-feat
 | 
						|
a member feature
 | 
						|
    section=None
 | 
						|
@two is undocumented
 | 
						|
doc symbol=Base
 | 
						|
    body=
 | 
						|
 | 
						|
    arg=base1
 | 
						|
 description starts on a new line,
 | 
						|
 minimally indented
 | 
						|
doc symbol=Variant1
 | 
						|
    body=
 | 
						|
A paragraph
 | 
						|
 | 
						|
Another paragraph
 | 
						|
 | 
						|
@var1 is undocumented
 | 
						|
    arg=var1
 | 
						|
 | 
						|
    feature=variant1-feat
 | 
						|
a feature
 | 
						|
    feature=member-feat
 | 
						|
a member feature
 | 
						|
doc symbol=Variant2
 | 
						|
    body=
 | 
						|
 | 
						|
doc symbol=Object
 | 
						|
    body=
 | 
						|
 | 
						|
    feature=union-feat1
 | 
						|
a feature
 | 
						|
doc symbol=Alternate
 | 
						|
    body=
 | 
						|
 | 
						|
    arg=i
 | 
						|
description starts on the same line
 | 
						|
    remainder indented the same
 | 
						|
    @b is undocumented
 | 
						|
    arg=b
 | 
						|
 | 
						|
    feature=alt-feat
 | 
						|
a feature
 | 
						|
doc freeform
 | 
						|
    body=
 | 
						|
== Another subsection
 | 
						|
doc symbol=cmd
 | 
						|
    body=
 | 
						|
 | 
						|
    arg=arg1
 | 
						|
    description starts on a new line,
 | 
						|
    indented
 | 
						|
    arg=arg2
 | 
						|
description starts on the same line
 | 
						|
    remainder indented differently
 | 
						|
    arg=arg3
 | 
						|
 | 
						|
    feature=cmd-feat1
 | 
						|
a feature
 | 
						|
    feature=cmd-feat2
 | 
						|
another feature
 | 
						|
    section=None
 | 
						|
.. note:: @arg3 is undocumented
 | 
						|
    section=Returns
 | 
						|
@Object
 | 
						|
    section=Errors
 | 
						|
some
 | 
						|
    section=TODO
 | 
						|
frobnicate
 | 
						|
    section=None
 | 
						|
.. admonition:: Notes
 | 
						|
 | 
						|
 - Lorem ipsum dolor sit amet
 | 
						|
 - Ut enim ad minim veniam
 | 
						|
 | 
						|
 Duis aute irure dolor
 | 
						|
 | 
						|
.. qmp-example::
 | 
						|
   :title: Ideal fast-food burger situation
 | 
						|
 | 
						|
   -> "in"
 | 
						|
   <- "out"
 | 
						|
 | 
						|
Examples::
 | 
						|
 | 
						|
 - Not a QMP code block
 | 
						|
 - Merely a preformatted code block literal
 | 
						|
 It isn't even an rST list.
 | 
						|
 - *verbatim*
 | 
						|
 - {braces}
 | 
						|
 | 
						|
Note::
 | 
						|
    Ceci n'est pas une note
 | 
						|
    section=Since
 | 
						|
2.10
 | 
						|
doc symbol=cmd-boxed
 | 
						|
    body=
 | 
						|
If you're bored enough to read this, go see a video of boxed cats
 | 
						|
    feature=cmd-feat1
 | 
						|
a feature
 | 
						|
    feature=cmd-feat2
 | 
						|
another feature
 | 
						|
    section=None
 | 
						|
.. qmp-example::
 | 
						|
 | 
						|
   -> "this example"
 | 
						|
 | 
						|
   <- "has no title"
 | 
						|
doc symbol=EVT_BOXED
 | 
						|
    body=
 | 
						|
 | 
						|
    feature=feat3
 | 
						|
a feature
 |