Index: third_party/protobuf/python/google/protobuf/pyext/cpp_message.py |
diff --git a/third_party/protobuf/python/google/protobuf/internal/message_cpp_test.py b/third_party/protobuf/python/google/protobuf/pyext/cpp_message.py |
similarity index 63% |
copy from third_party/protobuf/python/google/protobuf/internal/message_cpp_test.py |
copy to third_party/protobuf/python/google/protobuf/pyext/cpp_message.py |
index 0d84b3207bdd0a5f5b7202e9ad67d6cfcf55e0d3..037bb72c7df8e8338b96a282c4d2e8fcd8d08351 100644 |
--- a/third_party/protobuf/python/google/protobuf/internal/message_cpp_test.py |
+++ b/third_party/protobuf/python/google/protobuf/pyext/cpp_message.py |
@@ -1,8 +1,6 @@ |
-#! /usr/bin/python |
-# |
# Protocol Buffers - Google's data interchange format |
# Copyright 2008 Google Inc. All rights reserved. |
-# http://code.google.com/p/protobuf/ |
+# https://developers.google.com/protocol-buffers/ |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions are |
@@ -30,16 +28,30 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-"""Tests for google.protobuf.internal.message_cpp.""" |
+"""Protocol message implementation hooks for C++ implementation. |
+ |
+Contains helper functions used to create protocol message classes from |
+Descriptor objects at runtime backed by the protocol buffer C++ API. |
+""" |
+ |
+__author__ = 'tibell@google.com (Johan Tibell)' |
-__author__ = 'shahms@google.com (Shahms King)' |
+from google.protobuf.pyext import _message |
+from google.protobuf import message |
-import os |
-os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' |
-import unittest |
-from google.protobuf.internal.message_test import * |
+def NewMessage(bases, message_descriptor, dictionary): |
+ """Creates a new protocol message *class*.""" |
+ new_bases = [] |
+ for base in bases: |
+ if base is message.Message: |
+ # _message.Message must come before message.Message as it |
+ # overrides methods in that class. |
+ new_bases.append(_message.Message) |
+ new_bases.append(base) |
+ return tuple(new_bases) |
-if __name__ == '__main__': |
- unittest.main() |
+def InitMessage(message_descriptor, cls): |
+ """Finalizes the creation of a message class.""" |
+ cls.AddDescriptors(message_descriptor) |