From 776574d6417cf623fb071987cdd2c6bc13271dc2 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Fri, 2 Sep 2011 12:34:46 -0500 Subject: qapi: add code generation support for middle mode To get the ball rolling merging QAPI, this patch introduces a "middle mode" to the code generator. In middle mode, the code generator generates marshalling functions that are compatible with the current QMP server. We absolutely need to replace the current QMP server in order to support proper asynchronous commands but using a middle mode provides a middle-ground that lets us start converting commands in tree. Note that all of the commands have been converted already in my glib branch. Middle mode only exists until we finish merging them from my branch into the main tree. Signed-off-by: Anthony Liguori Signed-off-by: Luiz Capitulino --- scripts/qapi-types.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/qapi-types.py') diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index cece32546a..fc0f7af8f6 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -268,3 +268,6 @@ fdecl.write(''' fdecl.flush() fdecl.close() + +fdef.flush() +fdef.close() -- cgit 1.4.1 From 75b96aca6ff53c7e782efe670045376df4f7d199 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Thu, 15 Sep 2011 14:39:53 -0500 Subject: qapi: generate qapi_free_* functions for *List types Reviewed-by: Anthony Liguori Signed-off-by: Michael Roth Signed-off-by: Luiz Capitulino --- scripts/qapi-types.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts/qapi-types.py') diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index fc0f7af8f6..4797a70813 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -254,6 +254,8 @@ for expr in exprs: ret = "\n" if expr.has_key('type'): ret += generate_struct(expr['type'], "", expr['data']) + "\n" + ret += generate_type_cleanup_decl(expr['type'] + "List") + fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n") ret += generate_type_cleanup_decl(expr['type']) fdef.write(generate_type_cleanup(expr['type']) + "\n") elif expr.has_key('union'): -- cgit 1.4.1 From d2a80d6bb3fdf319d28f25eb034b32a9f3da7334 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Wed, 28 Sep 2011 16:56:56 -0300 Subject: qapi: Don't use c_var() on enum strings Otherwise if we have something like 'foo-bar' in the schema, it will be generated as 'foo_bar' in the string lookup table. c_var() is good for C variables, but not for enum strings. Signed-off-by: Luiz Capitulino --- scripts/qapi-types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/qapi-types.py') diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 4797a70813..3bacc0c0da 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -70,7 +70,7 @@ const char *%(name)s_lookup[] = { ret += mcgen(''' "%(value)s", ''', - value=c_var(value).lower()) + value=value.lower()) ret += mcgen(''' NULL, -- cgit 1.4.1 From 303b54b1a2611eda47abb28546869c49b5664f59 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Fri, 30 Sep 2011 12:43:27 -0300 Subject: qapi: Automatically generate a _MAX value for enums It's the last value in the enum and is very useful for the C implementation. Signed-off-by: Luiz Capitulino --- scripts/qapi-types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/qapi-types.py') diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 3bacc0c0da..f64d84c39e 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -91,8 +91,11 @@ typedef enum %(name)s ''', name=name) + # append automatically generated _MAX value + enum_values = values + [ 'MAX' ] + i = 0 - for value in values: + for value in enum_values: enum_decl += mcgen(''' %(abbrev)s_%(value)s = %(i)d, ''', -- cgit 1.4.1