Check members are all of a given type and call stubs for each type. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- python_modules/dissector.py | 50 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/python_modules/dissector.py b/python_modules/dissector.py index b6dd203..128e157 100644 --- a/python_modules/dissector.py +++ b/python_modules/dissector.py @@ -167,9 +167,55 @@ class SubDestination(Destination): return self.parent_dest.get_ref(self.member + "." + member, writer) -def write_member_parser(writer, container, member, dest, scope): +def write_switch(writer, container, switch, dest, scope): pass +def write_array(writer, container, member, array, dest, scope): + assert(container and member) + +def write_pointer(writer, container, member, t, dest, scope): + assert(t.is_pointer()) + +def write_struct(writer, member, t, index, dest, scope): + assert(t.is_struct()) + +def write_member_primitive(writer, container, member, t, dest, scope): + assert(t.is_primitive()) + +def write_member(writer, container, member, dest, scope): + + if member.has_attr("virtual"): + dest.write_ref(writer, 32, member.name, member.attributes["virtual"][0]) + return + + writer.comment(member.name) + writer.newline() + + if member.is_switch(): + write_switch(writer, container, member, dest, scope) + return + + if member.has_attr('ws_as'): + type_name = member.attributes['ws_as'][0] + assert(ptypes.type_exists(type_name)) + t = ptypes.lookup_type(type_name) + else: + t = member.member_type + + if t.is_pointer(): + # TODO case not handled + if not member.has_attr("nocopy"): + write_pointer(writer, container, member, t, dest, scope) + elif t.is_primitive(): + write_member_primitive(writer, container, member, t, dest, scope) + elif t.is_array(): + write_array(writer, container, member, t, dest, scope) + + elif t.is_struct(): + write_struct(writer, member, t, '-1', dest, scope) + else: + raise NotImplementedError("TODO can't handle parsing of %s" % t) + def write_container_parser(writer, container, dest): if container.has_attr('ws_as'): type_name = container.attributes['ws_as'][0] @@ -180,7 +226,7 @@ def write_container_parser(writer, container, dest): for m in container.members: if m.has_minor_attr(): writer.begin_block("if (minor >= %s)" % m.get_minor_attr()) - write_member_parser(writer, container, m, dest, scope) + write_member(writer, container, m, dest, scope) if m.has_minor_attr(): writer.end_block() -- 2.1.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel