فهرست منبع

qapi-event: Clean up how name of enum QAPIEvent is made

Use c_name() instead of ad hoc code.  Doesn't upcase the -p prefix,
which is an improvement in my book.  Unbreaks prefix containing '.',
but other funny characters remain broken.  To be fixed next.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster 10 سال پیش
والد
کامیت
016a335bd8
3فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 4 4
      docs/qapi-code-gen.txt
  2. 1 1
      scripts/qapi-event.py
  3. 1 1
      tests/test-qmp-event.c

+ 4 - 4
docs/qapi-code-gen.txt

@@ -826,7 +826,7 @@ Example:
         QDECREF(qmp);
         QDECREF(qmp);
     }
     }
 
 
-    const char *EXAMPLE_QAPIEvent_lookup[] = {
+    const char *example_QAPIEvent_lookup[] = {
         "MY_EVENT",
         "MY_EVENT",
         NULL,
         NULL,
     };
     };
@@ -843,11 +843,11 @@ Example:
 
 
     void qapi_event_send_my_event(Error **errp);
     void qapi_event_send_my_event(Error **errp);
 
 
-    extern const char *EXAMPLE_QAPIEvent_lookup[];
-    typedef enum EXAMPLE_QAPIEvent
+    extern const char *example_QAPIEvent_lookup[];
+    typedef enum example_QAPIEvent
     {
     {
         EXAMPLE_QAPI_EVENT_MY_EVENT = 0,
         EXAMPLE_QAPI_EVENT_MY_EVENT = 0,
         EXAMPLE_QAPI_EVENT_MAX = 1,
         EXAMPLE_QAPI_EVENT_MAX = 1,
-    } EXAMPLE_QAPIEvent;
+    } example_QAPIEvent;
 
 
     #endif
     #endif

+ 1 - 1
scripts/qapi-event.py

@@ -267,7 +267,7 @@ def generate_event_enum_lookup(event_enum_name, event_enum_strings):
 
 
 exprs = parse_schema(input_file)
 exprs = parse_schema(input_file)
 
 
-event_enum_name = prefix.upper().replace('-', '_') + "QAPIEvent"
+event_enum_name = c_name(prefix + "QAPIEvent", protect=False)
 event_enum_values = []
 event_enum_values = []
 event_enum_strings = []
 event_enum_strings = []
 
 

+ 1 - 1
tests/test-qmp-event.c

@@ -94,7 +94,7 @@ static bool qdict_cmp_simple(QDict *a, QDict *b)
 
 
 /* This function is hooked as final emit function, which can verify the
 /* This function is hooked as final emit function, which can verify the
    correctness. */
    correctness. */
-static void event_test_emit(TEST_QAPIEvent event, QDict *d, Error **errp)
+static void event_test_emit(test_QAPIEvent event, QDict *d, Error **errp)
 {
 {
     QObject *obj;
     QObject *obj;
     QDict *t;
     QDict *t;