示例#1
0
 def visit_alternate_type(self, name, info, ifcond, features, variants):
     with ifcontext(ifcond, self._genh):
         self._genh.preamble_add(gen_fwd_object_or_array(name))
     self._genh.add(gen_object(name, ifcond, None,
                               [variants.tag_member], variants))
     with ifcontext(ifcond, self._genh, self._genc):
         self._gen_type_cleanup(name)
示例#2
0
 def visit_object_type(self, name, info, ifcond, features,
                       base, members, variants):
     # Nothing to do for the special empty builtin
     if name == 'q_empty':
         return
     with ifcontext(ifcond, self._genh):
         self._genh.preamble_add(gen_fwd_object_or_array(name))
     self._genh.add(gen_object(name, ifcond, base, members, variants))
     with ifcontext(ifcond, self._genh, self._genc):
         if base and not base.is_implicit():
             self._genh.add(gen_upcast(name, base))
         # TODO Worth changing the visitor signature, so we could
         # directly use rather than repeat type.is_implicit()?
         #if not name.startswith('q_'):
             # implicit types won't be directly allocated/freed
         self._gen_type_cleanup(name)
示例#3
0
 def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
                   success_response, boxed, allow_oob, allow_preconfig,
                   features):
     if not gen:
         return
     # FIXME: If T is a user-defined type, the user is responsible
     # for making this work, i.e. to make T's condition the
     # conjunction of the T-returning commands' conditions.  If T
     # is a built-in type, this isn't possible: the
     # qmp_marshal_output_T() will be generated unconditionally.
     if ret_type and ret_type not in self._visited_ret_types[self._genc]:
         self._visited_ret_types[self._genc].add(ret_type)
         with ifcontext(ret_type.ifcond, self._genh, self._genc):
             self._genc.add(gen_marshal_rpc(ret_type))
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type))
         self._genc.add(gen_rpc_call(name, arg_type, boxed, ret_type))
示例#4
0
 def visit_event(self, name, info, ifcond, arg_type, boxed):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_event_send_decl(name, arg_type, boxed))
         self._genc.add(gen_event_send(name, arg_type, boxed,
                                       self._event_enum_name,
                                       self._event_emit_name))
     # Note: we generate the enum member regardless of @ifcond, to
     # keep the enumeration usable in target-independent code.
     self._event_enum_members.append(QAPISchemaEnumMember(name, None))
示例#5
0
 def visit_event(self, name, info, ifcond, features, arg_type, boxed):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_event_dispatch_decl(name, arg_type, boxed))
         self._genc.add(gen_event_dispatch(name, arg_type, boxed,
                                       self._event_enum_name,
                                       self._event_dispatch_name))
         self._event_registry.append((ifcond, c_enum_const(self._event_enum_name, name), 'qapi_event_dispatch_%s' % name, build_handler_name(name)))
     # Note: we generate the enum member regardless of @ifcond, to
     # keep the enumeration usable in target-independent code.
     self._event_enum_members.append(QAPISchemaEnumMember(name, None))
示例#6
0
 def visit_object_type(self, name, info, ifcond, features, base, members,
                       variants):
     # Nothing to do for the special empty builtin
     if name == 'q_empty':
         return
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_visit_members_decl(name))
         self._genc.add(
             gen_visit_object_members(name, base, members, variants))
         # TODO Worth changing the visitor signature, so we could
         # directly use rather than repeat type.is_implicit()?
         #if not name.startswith('q_'):
         # only explicit types need an allocating visit
         self._genh.add(gen_visit_decl(name))
         self._genc.add(gen_visit_object(name, base, members, variants))
示例#7
0
 def visit_alternate_type(self, name, info, ifcond, features, variants):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_visit_decl(name))
         self._genc.add(gen_visit_alternate(name, variants))
示例#8
0
 def visit_array_type(self, name, info, ifcond, element_type):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_visit_decl(name))
         self._genc.add(gen_visit_list(name, element_type))
示例#9
0
 def visit_enum_type(self, name, info, ifcond, features, members, prefix):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.add(gen_visit_decl(name, scalar=True))
         self._genc.add(gen_visit_enum(name))
示例#10
0
 def visit_array_type(self, name, info, ifcond, element_type):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.preamble_add(gen_fwd_object_or_array(name))
         self._genh.add(gen_array(name, element_type))
         self._gen_type_cleanup(name)
示例#11
0
 def visit_enum_type(self, name, info, ifcond, features, members, prefix):
     with ifcontext(ifcond, self._genh, self._genc):
         self._genh.preamble_add(gen_enum(name, members, prefix))
         self._genc.add(gen_enum_lookup(name, members, prefix))