OLD | NEW |
1 # Protocol Buffers - Google's data interchange format | 1 # Protocol Buffers - Google's data interchange format |
2 # Copyright 2008 Google Inc. All rights reserved. | 2 # Copyright 2008 Google Inc. All rights reserved. |
3 # http://code.google.com/p/protobuf/ | 3 # http://code.google.com/p/protobuf/ |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 30 matching lines...) Expand all Loading... |
41 output by the protocol compiler at compile-time. | 41 output by the protocol compiler at compile-time. |
42 | 42 |
43 The upshot of all this is that the real implementation | 43 The upshot of all this is that the real implementation |
44 details for ALL pure-Python protocol buffers are *here in | 44 details for ALL pure-Python protocol buffers are *here in |
45 this file*. | 45 this file*. |
46 """ | 46 """ |
47 | 47 |
48 __author__ = 'robinson@google.com (Will Robinson)' | 48 __author__ = 'robinson@google.com (Will Robinson)' |
49 | 49 |
50 | 50 |
51 from google.protobuf.internal import api_implementation | 51 from protobuf26.internal import api_implementation |
52 from google.protobuf import descriptor as descriptor_mod | 52 from protobuf26 import descriptor as descriptor_mod |
53 from google.protobuf import message | 53 from protobuf26 import message |
54 | 54 |
55 _FieldDescriptor = descriptor_mod.FieldDescriptor | 55 _FieldDescriptor = descriptor_mod.FieldDescriptor |
56 | 56 |
57 | 57 |
58 if api_implementation.Type() == 'cpp': | 58 if api_implementation.Type() == 'cpp': |
59 if api_implementation.Version() == 2: | 59 if api_implementation.Version() == 2: |
60 from google.protobuf.pyext import cpp_message | 60 from protobuf26.pyext import cpp_message |
61 _NewMessage = cpp_message.NewMessage | 61 _NewMessage = cpp_message.NewMessage |
62 _InitMessage = cpp_message.InitMessage | 62 _InitMessage = cpp_message.InitMessage |
63 else: | 63 else: |
64 from google.protobuf.internal import cpp_message | 64 from protobuf26.internal import cpp_message |
65 _NewMessage = cpp_message.NewMessage | 65 _NewMessage = cpp_message.NewMessage |
66 _InitMessage = cpp_message.InitMessage | 66 _InitMessage = cpp_message.InitMessage |
67 else: | 67 else: |
68 from google.protobuf.internal import python_message | 68 from protobuf26.internal import python_message |
69 _NewMessage = python_message.NewMessage | 69 _NewMessage = python_message.NewMessage |
70 _InitMessage = python_message.InitMessage | 70 _InitMessage = python_message.InitMessage |
71 | 71 |
72 | 72 |
73 class GeneratedProtocolMessageType(type): | 73 class GeneratedProtocolMessageType(type): |
74 | 74 |
75 """Metaclass for protocol message classes created at runtime from Descriptors. | 75 """Metaclass for protocol message classes created at runtime from Descriptors. |
76 | 76 |
77 We add implementations for all methods described in the Message class. We | 77 We add implementations for all methods described in the Message class. We |
78 also create properties to allow getting/setting all fields in the protocol | 78 also create properties to allow getting/setting all fields in the protocol |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 The Message class object described by the descriptor. | 196 The Message class object described by the descriptor. |
197 """ | 197 """ |
198 attributes = {} | 198 attributes = {} |
199 for name, nested_type in descriptor.nested_types_by_name.items(): | 199 for name, nested_type in descriptor.nested_types_by_name.items(): |
200 attributes[name] = MakeClass(nested_type) | 200 attributes[name] = MakeClass(nested_type) |
201 | 201 |
202 attributes[GeneratedProtocolMessageType._DESCRIPTOR_KEY] = descriptor | 202 attributes[GeneratedProtocolMessageType._DESCRIPTOR_KEY] = descriptor |
203 | 203 |
204 return GeneratedProtocolMessageType(str(descriptor.name), (message.Message,), | 204 return GeneratedProtocolMessageType(str(descriptor.name), (message.Message,), |
205 attributes) | 205 attributes) |
OLD | NEW |