mirror of https://github.com/xemu-project/xemu.git
qapi2texi: change texi formatters
STRUCT_FMT is generic enough, rename it to TYPE_FMT, use it for unions. Rename COMMAND_FMT to MSG_FMT, since it applies to both commands and events. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170125130308.16104-2-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
1883ff34b5
commit
597494abde
|
@ -9,7 +9,7 @@ import sys
|
||||||
|
|
||||||
import qapi
|
import qapi
|
||||||
|
|
||||||
COMMAND_FMT = """
|
MSG_FMT = """
|
||||||
@deftypefn {type} {{}} {name}
|
@deftypefn {type} {{}} {name}
|
||||||
|
|
||||||
{body}
|
{body}
|
||||||
|
@ -18,16 +18,7 @@ COMMAND_FMT = """
|
||||||
|
|
||||||
""".format
|
""".format
|
||||||
|
|
||||||
ENUM_FMT = """
|
TYPE_FMT = """
|
||||||
@deftp Enum {name}
|
|
||||||
|
|
||||||
{body}
|
|
||||||
|
|
||||||
@end deftp
|
|
||||||
|
|
||||||
""".format
|
|
||||||
|
|
||||||
STRUCT_FMT = """
|
|
||||||
@deftp {{{type}}} {name}
|
@deftp {{{type}}} {name}
|
||||||
|
|
||||||
{body}
|
{body}
|
||||||
|
@ -170,9 +161,9 @@ def texi_body(doc):
|
||||||
def texi_alternate(expr, doc):
|
def texi_alternate(expr, doc):
|
||||||
"""Format an alternate to texi"""
|
"""Format an alternate to texi"""
|
||||||
body = texi_body(doc)
|
body = texi_body(doc)
|
||||||
return STRUCT_FMT(type="Alternate",
|
return TYPE_FMT(type="Alternate",
|
||||||
name=doc.symbol,
|
name=doc.symbol,
|
||||||
body=body)
|
body=body)
|
||||||
|
|
||||||
|
|
||||||
def texi_union(expr, doc):
|
def texi_union(expr, doc):
|
||||||
|
@ -184,9 +175,9 @@ def texi_union(expr, doc):
|
||||||
union = "Simple Union"
|
union = "Simple Union"
|
||||||
|
|
||||||
body = texi_body(doc)
|
body = texi_body(doc)
|
||||||
return STRUCT_FMT(type=union,
|
return TYPE_FMT(type=union,
|
||||||
name=doc.symbol,
|
name=doc.symbol,
|
||||||
body=body)
|
body=body)
|
||||||
|
|
||||||
|
|
||||||
def texi_enum(expr, doc):
|
def texi_enum(expr, doc):
|
||||||
|
@ -195,32 +186,33 @@ def texi_enum(expr, doc):
|
||||||
if i not in doc.args:
|
if i not in doc.args:
|
||||||
doc.args[i] = ''
|
doc.args[i] = ''
|
||||||
body = texi_body(doc)
|
body = texi_body(doc)
|
||||||
return ENUM_FMT(name=doc.symbol,
|
return TYPE_FMT(type="Enum",
|
||||||
|
name=doc.symbol,
|
||||||
body=body)
|
body=body)
|
||||||
|
|
||||||
|
|
||||||
def texi_struct(expr, doc):
|
def texi_struct(expr, doc):
|
||||||
"""Format a struct to texi"""
|
"""Format a struct to texi"""
|
||||||
body = texi_body(doc)
|
body = texi_body(doc)
|
||||||
return STRUCT_FMT(type="Struct",
|
return TYPE_FMT(type="Struct",
|
||||||
name=doc.symbol,
|
name=doc.symbol,
|
||||||
body=body)
|
body=body)
|
||||||
|
|
||||||
|
|
||||||
def texi_command(expr, doc):
|
def texi_command(expr, doc):
|
||||||
"""Format a command to texi"""
|
"""Format a command to texi"""
|
||||||
body = texi_body(doc)
|
body = texi_body(doc)
|
||||||
return COMMAND_FMT(type="Command",
|
return MSG_FMT(type="Command",
|
||||||
name=doc.symbol,
|
name=doc.symbol,
|
||||||
body=body)
|
body=body)
|
||||||
|
|
||||||
|
|
||||||
def texi_event(expr, doc):
|
def texi_event(expr, doc):
|
||||||
"""Format an event to texi"""
|
"""Format an event to texi"""
|
||||||
body = texi_body(doc)
|
body = texi_body(doc)
|
||||||
return COMMAND_FMT(type="Event",
|
return MSG_FMT(type="Event",
|
||||||
name=doc.symbol,
|
name=doc.symbol,
|
||||||
body=body)
|
body=body)
|
||||||
|
|
||||||
|
|
||||||
def texi_expr(expr, doc):
|
def texi_expr(expr, doc):
|
||||||
|
|
Loading…
Reference in New Issue