|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: gentypes.py: Break out libxl_C_type_do_init
commit f710b76911903ae57505e2a9617c286edb6d6c39
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Tue Oct 29 15:19:33 2019 +0000
Commit: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CommitDate: Tue Nov 19 16:34:15 2019 +0000
libxl: gentypes.py: Break out libxl_C_type_do_init
This is going to be the common way to initialise things.
_libxl_C_type_init remains the thing for generating the body of the
init function, and for some special cases.
No functional change with existing types: C output is identical.
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Release-acked-by: Juergen Gross <jgross@xxxxxxxx>
Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
tools/libxl/gentypes.py | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 62883acb2e..124285cd66 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -165,6 +165,19 @@ def libxl_init_members(ty, nesting = 0):
else:
return []
+def libxl_C_type_do_init(ty, pass_arg, need_zero=True, indent=" "):
+ s=indent
+ if ty.init_val is not None:
+ s+= "%s = %s;\n" % (pass_arg(idl.PASS_BY_VALUE), ty.init_val)
+ elif ty.init_fn is not None:
+ s+= "%s(%s);\n" % (ty.init_fn, pass_arg(idl.PASS_BY_REFERENCE))
+ elif need_zero:
+ ptr = pass_arg(idl.PASS_BY_REFERENCE)
+ s+= "memset(%s, 0, sizeof(*%s));\n" % (ptr, ptr)
+ else:
+ s=""
+ return s
+
def _libxl_C_type_init(ty, v, indent = " ", parent = None, subinit=False):
s = ""
if isinstance(ty, idl.KeyedUnion):
@@ -309,15 +322,7 @@ def libxl_C_type_copy_deprecated(field, v, indent = "
", vparent = None):
if field.type.dispose_fn is not None:
s+= " %s(%s);\n" % (field.type.dispose_fn,
field.type.pass_arg(v, vparent is None))
-
- s+= " "
- if field.type.init_val is not None:
- s+= "%s = %s;\n" % (field_val, field.type.init_val)
- elif field.type.init_fn is not None:
- s+= "%s(%s);\n" % (field.type.init_fn, field_ptr)
- else:
- s+= "memset(%s, 0, sizeof(*%s));\n" % (field_ptr, field_ptr)
-
+ s+=libxl_C_type_do_init(field.type, field_pass)
s+= "}\n"
if s != "":
--
generated by git-patchbot for /home/xen/git/xen.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |