Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
cpp_message.py50 linesDownload Raw Back to pyext
1# Protocol Buffers - Google's data interchange format2# Copyright 2008 Google Inc.  All rights reserved.3#4# Use of this source code is governed by a BSD-style5# license that can be found in the LICENSE file or at6# https://developers.google.com/open-source/licenses/bsd7 8"""Protocol message implementation hooks for C++ implementation.9 10Contains helper functions used to create protocol message classes from11Descriptor objects at runtime backed by the protocol buffer C++ API.12"""13 14__author__ = 'tibell@google.com (Johan Tibell)'15 16from google.protobuf.internal import api_implementation17 18 19# pylint: disable=protected-access20_message = api_implementation._c_module21# TODO: Remove this import after fix api_implementation22if _message is None:23  from google.protobuf.pyext import _message24 25 26class GeneratedProtocolMessageType(_message.MessageMeta):27 28  """Metaclass for protocol message classes created at runtime from Descriptors.29 30  The protocol compiler currently uses this metaclass to create protocol31  message classes at runtime.  Clients can also manually create their own32  classes at runtime, as in this example:33 34  mydescriptor = Descriptor(.....)35  factory = symbol_database.Default()36  factory.pool.AddDescriptor(mydescriptor)37  MyProtoClass = factory.GetPrototype(mydescriptor)38  myproto_instance = MyProtoClass()39  myproto.foo_field = 2340  ...41 42  The above example will not work for nested types. If you wish to include them,43  use reflection.MakeClass() instead of manually instantiating the class in44  order to create the appropriate class structure.45  """46 47  # Must be consistent with the protocol-compiler code in48  # proto2/compiler/internal/generator.*.49  _DESCRIPTOR_KEY = 'DESCRIPTOR'50 
codekingpro/portable-devtools · Team Ai