[libvirt] [(python) PATCH 0/2] Provide symbolic names for typed parameters

libvirt: Jiri Denemark (1): apibuild: Generate macro/@string attribute docs/apibuild.py | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) libvirt-python: Jiri Denemark (1): Provide symbolic names for typed parameters generator.py | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.4.2

If a macro has a string value, the @string attribute will contain the value. Otherwise @string attribute will be missing. For example, the following macro definition from libvirt-domain.h: /** * VIR_MIGRATE_PARAM_URI: * ... */ # define VIR_MIGRATE_PARAM_URI "migrate_uri" will result in <macro name='VIR_MIGRATE_PARAM_URI' file='libvirt-domain' string='migrate_uri'> <info><![CDATA[...]]></info> </macro> https://bugzilla.redhat.com/show_bug.cgi?id=1229199 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- docs/apibuild.py | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 18278db..d93d1d6 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -1028,9 +1028,12 @@ class CParser: name = string.split(name, '(') [0] except: pass - info = self.parseMacroComment(name, not self.is_header) + strValue = None + if len(lst) == 1 and lst[0][0] == '"' and lst[0][-1] == '"': + strValue = lst[0][1:-1] + (args, desc) = self.parseMacroComment(name, not self.is_header) self.index_add(name, self.filename, not self.is_header, - "macro", info) + "macro", (args, desc, strValue)) return token # @@ -2144,24 +2147,30 @@ class docBuilder: def serialize_macro(self, output, name): id = self.idx.macros[name] - output.write(" <macro name='%s' file='%s'>\n" % (name, + output.write(" <macro name='%s' file='%s'" % (name, self.modulename_file(id.header))) - if id.info is not None: - try: - (args, desc) = id.info - if desc is not None and desc != "": - output.write(" <info><![CDATA[%s]]></info>\n" % (desc)) - self.indexString(name, desc) - for arg in args: - (name, desc) = arg - if desc is not None and desc != "": - output.write(" <arg name='%s' info='%s'/>\n" % ( - name, escape(desc))) - self.indexString(name, desc) - else: - output.write(" <arg name='%s'/>\n" % (name)) - except: - pass + if id.info is None: + args = [] + desc = None + strValue = None + else: + (args, desc, strValue) = id.info + + if strValue is not None: + output.write(" string='%s'" % strValue) + output.write(">\n") + + if desc is not None and desc != "": + output.write(" <info><![CDATA[%s]]></info>\n" % (desc)) + self.indexString(name, desc) + for arg in args: + (name, desc) = arg + if desc is not None and desc != "": + output.write(" <arg name='%s' info='%s'/>\n" % ( + name, escape(desc))) + self.indexString(name, desc) + else: + output.write(" <arg name='%s'/>\n" % (name)) output.write(" </macro>\n") def serialize_union(self, output, field, desc): -- 2.4.2

On Mon, Jun 08, 2015 at 11:34:35 +0200, Jiri Denemark wrote:
If a macro has a string value, the @string attribute will contain the value. Otherwise @string attribute will be missing.
For example, the following macro definition from libvirt-domain.h:
/** * VIR_MIGRATE_PARAM_URI: * ... */ # define VIR_MIGRATE_PARAM_URI "migrate_uri"
will result in
<macro name='VIR_MIGRATE_PARAM_URI' file='libvirt-domain' string='migrate_uri'> <info><![CDATA[...]]></info> </macro>
https://bugzilla.redhat.com/show_bug.cgi?id=1229199
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- docs/apibuild.py | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-)
ACK, Peter

https://bugzilla.redhat.com/show_bug.cgi?id=1222795 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- generator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/generator.py b/generator.py index 676243c..2fc838c 100755 --- a/generator.py +++ b/generator.py @@ -10,6 +10,7 @@ enums = {} # { enumType: { enumConstant: enumValue } } lxc_enums = {} # { enumType: { enumConstant: enumValue } } qemu_enums = {} # { enumType: { enumConstant: enumValue } } event_ids = [] +params = [] # [ (parameName, paramValue)... ] import os import sys @@ -134,6 +135,9 @@ class docParser(xml.sax.handler.ContentHandler): lxc_enum(attrs['type'],attrs['name'],attrs['value']) elif attrs['file'] == "libvirt-qemu": qemu_enum(attrs['type'],attrs['name'],attrs['value']) + elif tag == "macro": + if "string" in attrs: + params.append((attrs['name'], attrs['string'])) def end(self, tag): if debug: @@ -1881,6 +1885,10 @@ def buildWrappers(module): classes.write("%s = %s\n" % (name,value)) classes.write("\n") + classes.write("# typed parameter names\n") + for name, value in params: + classes.write("%s = \"%s\"\n" % (name, value)) + classes.close() def qemuBuildWrappers(module): -- 2.4.2

On Mon, Jun 08, 2015 at 11:34:36 +0200, Jiri Denemark wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1222795
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- generator.py | 8 ++++++++ 1 file changed, 8 insertions(+)
ACK, Peter

On Mon, Jun 08, 2015 at 11:34:34 +0200, Jiri Denemark wrote:
libvirt:
Jiri Denemark (1): apibuild: Generate macro/@string attribute
docs/apibuild.py | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-)
libvirt-python:
Jiri Denemark (1): Provide symbolic names for typed parameters
generator.py | 8 ++++++++ 1 file changed, 8 insertions(+)
I pushed this series and the previous apibuild patch. Thanks for the reviews. Jirka
participants (2)
-
Jiri Denemark
-
Peter Krempa