Beispiel #1
0
    def get_msg_flat_scheme(self):
        """
               :return: .proto 文件描述
               """
        class_define = 'table %s {' % (self.get_proto_name())
        for i, filed in enumerate(self.fields_proto.values()):
            class_define = script_exporter.add_space_line(
                class_define, filed.get_define_flat_scheme())

        if self.is_child_message():
            class_define = script_exporter.add_line(class_define, '  }')
        else:
            class_define = script_exporter.add_line(class_define, '}')

        for msg in self.child_msgs:
            class_define = script_exporter.add_space_line(
                class_define, msg.get_msg_flat_scheme())

        if self.is_list_obj and not self.is_child_message():
            list_define = 'table %s%s {' % (self.get_proto_name(), ListSuffix)
            filed = custom_filed.Filed(self.name, self.get_proto_name(),
                                       ListSuffix, True)
            list_define = script_exporter.add_space_line(
                list_define, filed.get_define_flat_scheme())
            list_define = script_exporter.add_line(list_define, '}')
            class_define = script_exporter.add_line(class_define, list_define)
        return class_define
Beispiel #2
0
 def get_full_proto(self):
     info = 'syntax = "proto3";'
     if not utility.is_null_or_empty(self.name_space):
         info = script_exporter.add_line(info,
                                         "package %s;" % self.name_space)
     for msg_name in self.import_msgs:
         info = script_exporter.add_line(
             info, script_exporter.get_import_proto_define(msg_name))
     info = script_exporter.add_line(info, self.get_msg_proto())
     return info
Beispiel #3
0
 def get_list_lua_api(self):
     if self.is_list_obj and not self.is_child_message():
         api = '---@class %s ' % (self.get_proto_name())
         filed = custom_filed.Filed(self.name, self.name + self.suffix,
                                    ListSuffix, True)
         api = script_exporter.add_line(api, filed.get_lua_api())
         return api
     return None
Beispiel #4
0
    def get_full_flat_scheme(self):
        info = ''
        for msg_name in self.import_msgs:
            include_file = 'include "%s.fbs";' % msg_name
            if info == "":
                info = include_file
            else:
                info = script_exporter.add_line(info, include_file)

        if info == "":
            info = 'attribute "priority";'
        else:
            info = script_exporter.add_line(info, 'attribute "priority";')

        if not utility.is_null_or_empty(self.name_space):
            info = script_exporter.add_line(info,
                                            "namespace %s;" % self.name_space)

        info = script_exporter.add_line(info, self.get_msg_flat_scheme())
        if self.is_list_obj and not self.is_child_message():
            info = script_exporter.add_line(
                info, "root_type " + self.get_proto_name() + ListSuffix + ";")
        else:
            info = script_exporter.add_line(
                info, "root_type " + self.get_proto_name() + ";")
        return info
Beispiel #5
0
 def get_msg_lua_api(self):
     api = '---@class %s ' % (self.name + self.suffix)
     for i, filed in enumerate(self.fields_proto.values()):
         api = script_exporter.add_line(api, filed.get_lua_api())
     # print(self.get_lua_script())
     return api