33 """Contains a metaclass and helper functions used to create
34 protocol message classes from Descriptor objects at runtime.
36 Recall that a metaclass is the "type" of a class.
37 (A class is to a metaclass what an instance is to a class.)
39 In this case, we use the GeneratedProtocolMessageType metaclass
40 to inject all the useful functionality into the classes
41 output by the protocol compiler at compile-time.
43 The upshot of all this is that the real implementation
44 details for ALL pure-Python protocol buffers are *here in
48 __author__ =
'robinson@google.com (Will Robinson)'
56 GeneratedProtocolMessageType = message_factory._GENERATED_PROTOCOL_MESSAGE_TYPE
58 MESSAGE_CLASS_CACHE = {}
63 """Generate a new Message instance from this Descriptor and a byte string.
65 DEPRECATED: ParseMessage is deprecated because it is using MakeClass().
66 Please use MessageFactory.GetPrototype() instead.
69 descriptor: Protobuf Descriptor object
70 byte_str: Serialized protocol buffer byte string
73 Newly created protobuf Message object.
76 new_msg = result_class()
77 new_msg.ParseFromString(byte_str)
83 """Construct a class object for a protobuf described by descriptor.
85 DEPRECATED: use MessageFactory.GetPrototype() instead.
88 descriptor: A descriptor.Descriptor object describing the protobuf.
90 The Message class object described by the descriptor.
95 return symbol_database.Default().GetPrototype(descriptor)