[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 32/47] qapi: Update qapi-code-gen.txt examples to mat
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 32/47] qapi: Update qapi-code-gen.txt examples to match current code |
Date: |
Fri, 1 Sep 2017 14:55:56 +0200 |
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
docs/devel/qapi-code-gen.txt | 47 +++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index 9903ac4c19..ae05327869 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -957,6 +957,8 @@ Example:
typedef struct UserDefOneList UserDefOneList;
+ typedef struct q_obj_my_command_arg q_obj_my_command_arg;
+
struct UserDefOne {
int64_t integer;
bool has_string;
@@ -972,6 +974,10 @@ Example:
void qapi_free_UserDefOneList(UserDefOneList *obj);
+ struct q_obj_my_command_arg {
+ UserDefOneList *arg1;
+ };
+
#endif
$ cat qapi-generated/example-qapi-types.c
[Uninteresting stuff omitted...]
@@ -1036,6 +1042,8 @@ Example:
void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj,
Error **errp);
void visit_type_UserDefOneList(Visitor *v, const char *name,
UserDefOneList **obj, Error **errp);
+ void visit_type_q_obj_my_command_arg_members(Visitor *v,
q_obj_my_command_arg *obj, Error **errp);
+
#endif
$ cat qapi-generated/example-qapi-visit.c
[Uninteresting stuff omitted...]
@@ -1104,6 +1112,9 @@ Example:
}
}
+ if (!err) {
+ visit_check_list(v, &err);
+ }
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_UserDefOneList(*obj);
@@ -1113,6 +1124,19 @@ Example:
error_propagate(errp, err);
}
+ void visit_type_q_obj_my_command_arg_members(Visitor *v,
q_obj_my_command_arg *obj, Error **errp)
+ {
+ Error *err = NULL;
+
+ visit_type_UserDefOneList(v, "arg1", &obj->arg1, &err);
+ if (err) {
+ goto out;
+ }
+
+ out:
+ error_propagate(errp, err);
+ }
+
=== scripts/qapi-commands.py ===
Used to generate the marshaling/dispatch functions for the commands
@@ -1145,9 +1169,12 @@ Example:
#include "example-qapi-types.h"
#include "qapi/qmp/qdict.h"
+ #include "qapi/qmp/dispatch.h"
#include "qapi/error.h"
+ void example_qmp_init_marshal(QmpCommandList *cmds);
UserDefOne *qmp_my_command(UserDefOneList *arg1, Error **errp);
+ void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp);
#endif
$ cat qapi-generated/example-qmp-marshal.c
@@ -1170,19 +1197,19 @@ Example:
visit_free(v);
}
- static void qmp_marshal_my_command(QDict *args, QObject **ret, Error
**errp)
+ void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp)
{
Error *err = NULL;
UserDefOne *retval;
Visitor *v;
- UserDefOneList *arg1 = NULL;
+ q_obj_my_command_arg arg = {0};
v = qobject_input_visitor_new(QOBJECT(args));
visit_start_struct(v, NULL, NULL, 0, &err);
if (err) {
goto out;
}
- visit_type_UserDefOneList(v, "arg1", &arg1, &err);
+ visit_type_q_obj_my_command_arg_members(v, &arg, &err);
if (!err) {
visit_check_struct(v, &err);
}
@@ -1191,7 +1218,7 @@ Example:
goto out;
}
- retval = qmp_my_command(arg1, &err);
+ retval = qmp_my_command(arg.arg1, &err);
if (err) {
goto out;
}
@@ -1203,17 +1230,18 @@ Example:
visit_free(v);
v = qapi_dealloc_visitor_new();
visit_start_struct(v, NULL, NULL, 0, NULL);
- visit_type_UserDefOneList(v, "arg1", &arg1, NULL);
+ visit_type_q_obj_my_command_arg_members(v, &arg, NULL);
visit_end_struct(v, NULL);
visit_free(v);
}
- static void qmp_init_marshal(void)
+ void example_qmp_init_marshal(QmpCommandList *cmds)
{
- qmp_register_command("my-command", qmp_marshal_my_command,
QCO_NO_OPTIONS);
- }
+ QTAILQ_INIT(cmds);
- qapi_init(qmp_init_marshal);
+ qmp_register_command(cmds, "my-command",
+ qmp_marshal_my_command, QCO_NO_OPTIONS);
+ }
=== scripts/qapi-event.py ===
@@ -1258,6 +1286,7 @@ Example:
QDict *qmp;
Error *err = NULL;
QMPEventFuncEmit emit;
+
emit = qmp_event_get_func_emit();
if (!emit) {
return;
--
2.13.5
- [Qemu-devel] [PULL 03/47] qobject: Explain how QNum works, and why, (continued)
- [Qemu-devel] [PULL 03/47] qobject: Explain how QNum works, and why, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 13/47] tests/check-qlit: New, covering qobject/qlit.c, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 05/47] qlit: move qlit from check-qjson to qobject/, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 17/47] qapi-schema: Introspection doc is in the wrong section, fix, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 10/47] qlit: make qlit_equal_qobject() take const arguments, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 29/47] qapi-schema: Make block-core.json self-contained, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 07/47] qlit: Change compound literals to initializers, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 31/47] qapi-schema: Improve section headings, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 41/47] qapi: Use qapi_enum_parse() in input_type_enum(), Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 06/47] qlit: use QLit prefix consistently, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 32/47] qapi: Update qapi-code-gen.txt examples to match current code,
Markus Armbruster <=
- [Qemu-devel] [PULL 26/47] qapi-schema: Collect TPM stuff in qapi/tpm.json, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 18/47] qapi-schema: Rocker doc section contains unrelated stuff, fix, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 02/47] tests/qmp-test: Add generic, basic test of query commands, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 33/47] qapi: Drop superfluous qapi_enum_parse() parameter max, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 27/47] qapi-schema: Move block events from event.json to block.json, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 37/47] hmp: Use qapi_enum_parse() in hmp_migrate_set_parameter(), Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 12/47] qlit: Replace open-coded qnum_get_int() by call, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 28/47] qapi-schema: Fold event.json back into qapi-schema.json, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 09/47] qlit: make qlit_equal_qobject return a bool, Markus Armbruster, 2017/09/01
- [Qemu-devel] [PULL 20/47] qapi-schema: Collect run state stuff in qapi/run-state.json, Markus Armbruster, 2017/09/01