diff mbox

[v3,1/4] ocaml/gen: fix ocaml type/code generator from IDL

Message ID 20170303122508.87465-2-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monne March 3, 2017, 12:25 p.m. UTC
From: Ian Jackson <ian.jackson@eu.citrix.com>

This patch adds support for union members which have their own type name.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
This is a pre-requisite for the PVHv1 removal patch.
---
Cc: David Scott <dave@recoil.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 tools/ocaml/libs/xl/genwrap.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Wei Liu March 13, 2017, 4:49 p.m. UTC | #1
On Fri, Mar 03, 2017 at 12:25:05PM +0000, Roger Pau Monne wrote:
> From: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> This patch adds support for union members which have their own type name.
> 
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>

Reviewed-by: Wei Liu <wei.liu2@citrix.com>
David Scott March 13, 2017, 7:55 p.m. UTC | #2
> On 13 Mar 2017, at 16:49, Wei Liu <wei.liu2@citrix.com> wrote:
> 
> On Fri, Mar 03, 2017 at 12:25:05PM +0000, Roger Pau Monne wrote:
>> From: Ian Jackson <ian.jackson@eu.citrix.com>
>> 
>> This patch adds support for union members which have their own type name.
>> 
>> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
> 

Under the assumption that the generated code still compiles ;-) looks ok to me too.

Acked-by: David Scott <dave@recoil.org>
diff mbox

Patch

diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
index 1c8ad81..9a65d73 100644
--- a/tools/ocaml/libs/xl/genwrap.py
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -155,7 +155,7 @@  def gen_ocaml_keyedunions(ty, interface, indent, parent = None):
                 u.append("%s" % (f.name.capitalize()))
             elif isinstance(f.type, idl.Struct):
                 if f.type.rawname is not None:
-                    u.append("%s of %s" % (f.name.capitalize(), f.type.rawname.capitalize()))
+                    u.append("%s of %s.t" % (f.name.capitalize(), f.type.rawname.capitalize()))
                 elif f.type.has_fields():
                     u.append("%s of %s_%s" % (f.name.capitalize(), nparent, f.name))
                 else:
@@ -325,7 +325,7 @@  def c_val(ty, c, o, indent="", parent = None):
                 s += "\t\t    case %d:\n" % (n)
                 s += "\t\t        %s = %s;\n" % (parent + ty.keyvar.name, f.enumname)
                 (nparent,fexpr) = ty.member(c, f, False)
-                s += "%s" % c_val(f.type, fexpr, "Field(%s, 0)" % o, indent=indent+"\t\t        ")
+                s += "%s" % c_val(f.type, fexpr, "Field(%s, 0)" % o, parent=nparent, indent=indent+"\t\t        ")
                 s += "break;\n"
                 n += 1
         s += "\t\t    default: failwith_xl(ERROR_FAIL, \"variant handling bug %s%s (block)\"); break;\n" % (parent, ty.keyvar.name)