Exemplo n.º 1
0
 def write_field_definition(field_name, field_type, *_):
     field_name = util.format_to_camel(field_name)
     field_type = util.format_to_pascal(
         field_type) if field_type in self._custom_enums else field_type
     f.write('%spublic readonly %s %s;\n' % (
         TAB2,
         field_type,
         field_name,
     ))
Exemplo n.º 2
0
 def write_field(field_name, field_type, *_):
     field_name = util.format_to_camel(field_name)
     if field_type == "string" and _[1]:
         f.write("%swriter.Write(wrapString(%s, %i));\n" % (TAB3, field_name, _[1]))
     elif field_type == "int[]":
         f.write("%swriter.Write((int)%s.Length);\n" % (TAB3, field_name))
         f.write("%sfor (int i = 0; i < %s.Length; i++)\n" % (TAB3, field_name))
         f.write("%swriter.Write(%s[i]);\n" % (TAB4, field_name))
         f.write("\n")
     else:
         f.write("%swriter.Write(%s);\n" % (TAB3, field_name))
Exemplo n.º 3
0
 def read_from_byte_array(field_name, field_type, *_):
     field_name = util.format_to_camel(field_name)
     if field_type == "string" and _[1] == "long":
         f.write("%svar len = reader.ReadInt16();\n" % (TAB3,))
         f.write("%schar[] strRaw = reader.ReadChars(len);\n" % (TAB3,))
         f.write("%s%s = new string(strRaw);\n" % (TAB3, field_name))
     else:
         method = reader_method(field_type)
         if field_type in self._custom_enums:
             f.write("%s%s = (%s)reader.%s();\n" % (TAB3, field_name, util.format_to_pascal(field_type), method))
         elif method is not None:
             f.write("%s%s = reader.%s();\n" % (TAB3, field_name, method))
Exemplo n.º 4
0
 def write_field(field_name, field_type, *_):
     field_name = util.format_to_camel(field_name)
     if field_type == 'string' and _[1]:
         f.write('%swriter.Write(wrapString(%s, %i));\n' %
                 (TAB3, field_name, _[1]))
     elif field_type == 'int[]':
         f.write('%swriter.Write((int)%s.Length);\n' %
                 (TAB3, field_name))
         f.write('%sfor (int i = 0; i < %s.Length; i++)\n' %
                 (TAB3, field_name))
         f.write('%swriter.Write(%s[i]);\n' % (TAB4, field_name))
         f.write('\n')
     else:
         f.write('%swriter.Write(%s);\n' % (
             TAB3,
             field_name,
         ))
Exemplo n.º 5
0
 def read_from_byte_array(field_name, field_type, *_):
     field_name = util.format_to_camel(field_name)
     if field_type == 'string' and _[1] == 'long':
         f.write('%svar len = reader.ReadInt16();\n' % (TAB3, ))
         f.write('%schar[] strRaw = reader.ReadChars(len);\n' %
                 (TAB3, ))
         f.write('%s%s = new string(strRaw);\n' % (TAB3, field_name))
     else:
         method = reader_method(field_type)
         if field_type in self._custom_enums:
             f.write('%s%s = (%s)reader.%s();\n' % (
                 TAB3,
                 field_name,
                 util.format_to_pascal(field_type),
                 method,
             ))
         elif method is not None:
             f.write('%s%s = reader.%s();\n' % (
                 TAB3,
                 field_name,
                 method,
             ))
Exemplo n.º 6
0
 def write_fields_init(field_name, *_):
     field_name = util.format_to_camel(field_name)
     f.write("%sthis.%s = %s;\n" % (TAB3, field_name, field_name))
Exemplo n.º 7
0
 def write_constructor_args(field_name, field_type, last, *_):
     field_name = util.format_to_camel(field_name)
     spacing = " " if last else ", "
     f.write("%s %s%s" % (field_type, field_name, spacing))
Exemplo n.º 8
0
 def write_field_definition(field_name, field_type, *_):
     field_name = util.format_to_camel(field_name)
     field_type = util.format_to_pascal(field_type) if field_type in self._custom_enums else field_type
     f.write("%spublic readonly %s %s;\n" % (TAB2, field_type, field_name))
Exemplo n.º 9
0
 def write_fields_init(field_name, *_):
     field_name = util.format_to_camel(field_name)
     f.write('%sthis.%s = %s;\n' % (TAB3, field_name, field_name))
Exemplo n.º 10
0
 def write_constructor_args(field_name, field_type, last, *_):
     field_name = util.format_to_camel(field_name)
     spacing = ' ' if last else ', '
     f.write('%s %s%s' % (field_type, field_name, spacing))