Code generate Swift wrappers for protocol buffers.
This commit is contained in:
parent
aefbc3c0b2
commit
73f22ae62e
|
@ -52,6 +52,8 @@ class LineWriter:
|
||||||
|
|
||||||
def pop_indent(self):
|
def pop_indent(self):
|
||||||
self.current_indent = self.current_indent - 1
|
self.current_indent = self.current_indent - 1
|
||||||
|
if self.current_indent < 0:
|
||||||
|
raise Exception('Invalid indentation')
|
||||||
|
|
||||||
def all_context_proto_names(self):
|
def all_context_proto_names(self):
|
||||||
return [context.proto_name for context in self.contexts]
|
return [context.proto_name for context in self.contexts]
|
||||||
|
@ -194,8 +196,7 @@ class BaseContext(object):
|
||||||
elif field.rules == 'repeated':
|
elif field.rules == 'repeated':
|
||||||
return '[%s]' % base_type
|
return '[%s]' % base_type
|
||||||
else:
|
else:
|
||||||
# TODO: fail
|
raise Exception('Unknown field type')
|
||||||
return base_type
|
|
||||||
|
|
||||||
def is_field_primitive(self, field):
|
def is_field_primitive(self, field):
|
||||||
return field.proto_type in ('uint64',
|
return field.proto_type in ('uint64',
|
||||||
|
@ -441,6 +442,7 @@ class MessageContext(BaseContext):
|
||||||
writer.newline()
|
writer.newline()
|
||||||
elif field.rules == 'repeated':
|
elif field.rules == 'repeated':
|
||||||
writer.add('@objc public var %s: %s {' % (field.name_swift, field.type_swift_not_optional))
|
writer.add('@objc public var %s: %s {' % (field.name_swift, field.type_swift_not_optional))
|
||||||
|
writer.push_indent()
|
||||||
writer.add('return proto.%s' % field.name_swift )
|
writer.add('return proto.%s' % field.name_swift )
|
||||||
writer.pop_indent()
|
writer.pop_indent()
|
||||||
writer.add('}')
|
writer.add('}')
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue