41 |
42 | class Widget {
43 | public:
44 | Widget(int number, const std::string& name);
45 | ~Widget();
46 |
47 | // Public accessors to number data
48 | float GetFloatValue() const;
49 | int GetIntValue() const;
50 |
51 | // Public accessors to the string data
52 | std::string GetStringValue() const;
53 | void GetCharPtrValue(char* buffer, size_t max_size) const;
54 |
55 | private:
56 | // Data members
57 | float number_;
58 | std::string name_;
59 | };
60 |
--------------------------------------------------------------------------------
/compiler/src/google/protobuf/unittest_embed_optimize_for.proto:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | // Author: kenton@google.com (Kenton Varda)
32 | // Based on original Protocol Buffers design by
33 | // Sanjay Ghemawat, Jeff Dean, and others.
34 | //
35 | // A proto file which imports a proto file that uses optimize_for = CODE_SIZE.
36 |
37 | import "google/protobuf/unittest_optimize_for.proto";
38 |
39 | package protobuf_unittest;
40 |
41 | // We optimize for speed here, but we are importing a proto that is optimized
42 | // for code size.
43 | option optimize_for = SPEED;
44 |
45 | message TestEmbedOptimizedForSize {
46 | // Test that embedding a message which has optimize_for = CODE_SIZE into
47 | // one optimized for speed works.
48 | optional TestOptimizedForSize optional_message = 1;
49 | repeated TestOptimizedForSize repeated_message = 2;
50 | }
51 |
--------------------------------------------------------------------------------
/compiler/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | package com.google.protobuf;
32 |
33 | /**
34 | * Abstract interface for a blocking RPC channel. {@code BlockingRpcChannel}
35 | * is the blocking equivalent to {@link RpcChannel}.
36 | *
37 | * @author kenton@google.com Kenton Varda
38 | * @author cpovirk@google.com Chris Povirk
39 | */
40 | public interface BlockingRpcChannel {
41 | /**
42 | * Call the given method of the remote service and blocks until it returns.
43 | * {@code callBlockingMethod()} is the blocking equivalent to
44 | * {@link RpcChannel#callMethod}.
45 | */
46 | Message callBlockingMethod(
47 | Descriptors.MethodDescriptor method,
48 | RpcController controller,
49 | Message request,
50 | Message responsePrototype) throws ServiceException;
51 | }
52 |
--------------------------------------------------------------------------------
/compiler/gtest/include/gtest/gtest_prod.h:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // Google C++ Testing Framework definitions useful in production code.
33 |
34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
36 |
37 | // When you need to test the private or protected members of a class,
38 | // use the FRIEND_TEST macro to declare your tests as friends of the
39 | // class. For example:
40 | //
41 | // class MyClass {
42 | // private:
43 | // void MyMethod();
44 | // FRIEND_TEST(MyClassTest, MyMethod);
45 | // };
46 | //
47 | // class MyClassTest : public testing::Test {
48 | // // ...
49 | // };
50 | //
51 | // TEST_F(MyClassTest, MyMethod) {
52 | // // Can call MyClass::MyMethod() here.
53 | // }
54 |
55 | #define FRIEND_TEST(test_case_name, test_name)\
56 | friend class test_case_name##_##test_name##_Test
57 |
58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
59 |
--------------------------------------------------------------------------------
/compiler/gtest/test/gtest-param-test_test.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Authors: vladl@google.com (Vlad Losev)
31 | //
32 | // The Google C++ Testing Framework (Google Test)
33 | //
34 | // This header file provides classes and functions used internally
35 | // for testing Google Test itself.
36 |
37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
39 |
40 | #include
41 |
42 | #if GTEST_HAS_PARAM_TEST
43 |
44 | // Test fixture for testing definition and instantiation of a test
45 | // in separate translation units.
46 | class ExternalInstantiationTest : public ::testing::TestWithParam {};
47 |
48 | // Test fixture for testing instantiation of a test in multiple
49 | // translation units.
50 | class InstantiationInMultipleTranslaionUnitsTest
51 | : public ::testing::TestWithParam {};
52 |
53 | #endif // GTEST_HAS_PARAM_TEST
54 |
55 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
56 |
--------------------------------------------------------------------------------
/runtime/protobuf-ios/Classes/RingBuffer.m:
--------------------------------------------------------------------------------
1 | #import "RingBuffer.h"
2 |
3 | @implementation RingBuffer
4 |
5 | - (id)initWithData:(NSMutableData*)data {
6 | if ((self = [super init])) {
7 | buffer = [data retain];
8 | }
9 | return self;
10 | }
11 |
12 |
13 | - (NSUInteger)freeSpace {
14 | return (position < tail ? tail - position : (buffer.length - position) + tail) - (tail ? 1 : 0);
15 | }
16 |
17 |
18 | - (BOOL)appendByte:(uint8_t)byte {
19 | if (self.freeSpace < 1) return NO;
20 | ((uint8_t*)buffer.mutableBytes)[position++] = byte;
21 | return YES;
22 | }
23 |
24 |
25 | - (NSInteger)appendData:(const NSData*)value offset:(NSInteger)offset length:(NSInteger)length {
26 | NSInteger totalWritten = 0;
27 | const uint8_t *input = value.bytes;
28 | uint8_t *data = buffer.mutableBytes;
29 |
30 | if (position >= tail) {
31 | totalWritten = MIN(buffer.length - position, length);
32 | memcpy(data + position, input + offset, totalWritten);
33 | position += totalWritten;
34 | if (totalWritten == length) return length;
35 | length -= totalWritten;
36 | offset += totalWritten;
37 | }
38 |
39 | NSUInteger freeSpace = self.freeSpace;
40 | if (!freeSpace) return totalWritten;
41 |
42 | if (position == buffer.length) {
43 | position = 0;
44 | }
45 |
46 | // position < tail
47 | int32_t written = (int32_t)MIN(freeSpace, length);
48 | memcpy(data + position, input + offset, written);
49 | position += written;
50 | totalWritten += written;
51 |
52 | return totalWritten;
53 | }
54 |
55 |
56 | - (NSInteger)flushToOutputStream:(NSOutputStream*)stream {
57 | NSInteger totalWritten = 0;
58 | const uint8_t *data = buffer.bytes;
59 |
60 | if (tail > position) {
61 | int32_t written = (int32_t)[stream write:data + tail maxLength:buffer.length - tail];
62 | if (written <= 0) return totalWritten;
63 | totalWritten += written;
64 | tail += written;
65 | if (tail == buffer.length) {
66 | tail = 0;
67 | }
68 | }
69 |
70 | if (tail < position) {
71 | int32_t written = (int32_t)[stream write:data + tail maxLength:position - tail];
72 | if (written <= 0) return totalWritten;
73 | totalWritten += written;
74 | tail += written;
75 | }
76 |
77 | if (tail == position) {
78 | tail = position = 0;
79 | }
80 |
81 | if (position == buffer.length && tail > 0) {
82 | position = 0;
83 | }
84 |
85 | if (tail == buffer.length) {
86 | tail = 0;
87 | }
88 |
89 | return totalWritten;
90 | }
91 |
92 |
93 | - (void)dealloc {
94 | [buffer release];
95 | [super dealloc];
96 | }
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/compiler/gtest/xcode/Samples/FrameworkSample/widget.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: preston.jackson@gmail.com (Preston Jackson)
31 | //
32 | // Google Test - FrameworkSample
33 | // widget.cc
34 | //
35 |
36 | // Widget is a very simple class used for demonstrating the use of gtest
37 |
38 | #include "widget.h"
39 |
40 | Widget::Widget(int number, const std::string& name)
41 | : number_(number),
42 | name_(name) {}
43 |
44 | Widget::~Widget() {}
45 |
46 | float Widget::GetFloatValue() const {
47 | return number_;
48 | }
49 |
50 | int Widget::GetIntValue() const {
51 | return static_cast(number_);
52 | }
53 |
54 | std::string Widget::GetStringValue() const {
55 | return name_;
56 | }
57 |
58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const {
59 | // Copy the char* representation of name_ into buffer, up to max_size.
60 | strncpy(buffer, name_.c_str(), max_size-1);
61 | buffer[max_size-1] = '\0';
62 | return;
63 | }
64 |
--------------------------------------------------------------------------------
/compiler/src/google/protobuf/unittest_optimize_for.proto:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | // Author: kenton@google.com (Kenton Varda)
32 | // Based on original Protocol Buffers design by
33 | // Sanjay Ghemawat, Jeff Dean, and others.
34 | //
35 | // A proto file which uses optimize_for = CODE_SIZE.
36 |
37 | import "google/protobuf/unittest.proto";
38 |
39 | package protobuf_unittest;
40 |
41 | option optimize_for = CODE_SIZE;
42 |
43 | message TestOptimizedForSize {
44 | optional int32 i = 1;
45 | optional ForeignMessage msg = 19;
46 |
47 | extensions 1000 to max;
48 |
49 | extend TestOptimizedForSize {
50 | optional int32 test_extension = 1234;
51 | optional TestRequiredOptimizedForSize test_extension2 = 1235;
52 | }
53 | }
54 |
55 | message TestRequiredOptimizedForSize {
56 | required int32 x = 1;
57 | }
58 |
59 | message TestOptionalOptimizedForSize {
60 | optional TestRequiredOptimizedForSize o = 1;
61 | }
62 |
--------------------------------------------------------------------------------
/compiler/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | package com.google.protobuf;
32 |
33 | import com.google.protobuf.Descriptors.EnumDescriptor;
34 | import com.google.protobuf.Descriptors.EnumValueDescriptor;
35 |
36 | /**
37 | * Interface of useful methods added to all enums generated by the protocol
38 | * compiler.
39 | */
40 | public interface ProtocolMessageEnum extends Internal.EnumLite {
41 |
42 | /**
43 | * Return the value's numeric value as defined in the .proto file.
44 | */
45 | int getNumber();
46 |
47 | /**
48 | * Return the value's descriptor, which contains information such as
49 | * value name, number, and type.
50 | */
51 | EnumValueDescriptor getValueDescriptor();
52 |
53 | /**
54 | * Return the enum type's descriptor, which contains information
55 | * about each defined value, etc.
56 | */
57 | EnumDescriptor getDescriptorForType();
58 | }
59 |
--------------------------------------------------------------------------------
/compiler/python/README.txt:
--------------------------------------------------------------------------------
1 | Protocol Buffers - Google's data interchange format
2 | Copyright 2008 Google Inc.
3 |
4 | This directory contains the Python Protocol Buffers runtime library.
5 |
6 | Normally, this directory comes as part of the protobuf package, available
7 | from:
8 |
9 | http://code.google.com/p/protobuf
10 |
11 | The complete package includes the C++ source code, which includes the
12 | Protocol Compiler (protoc). If you downloaded this package from PyPI
13 | or some other Python-specific source, you may have received only the
14 | Python part of the code. In this case, you will need to obtain the
15 | Protocol Compiler from some other source before you can use this
16 | package.
17 |
18 | Development Warning
19 | ===================
20 |
21 | The Python implementation of Protocol Buffers is not as mature as the C++
22 | and Java implementations. It may be more buggy, and it is known to be
23 | pretty slow at this time. If you would like to help fix these issues,
24 | join the Protocol Buffers discussion list and let us know!
25 |
26 | Installation
27 | ============
28 |
29 | 1) Make sure you have Python 2.4 or newer. If in doubt, run:
30 |
31 | $ python -V
32 |
33 | 2) If you do not have setuptools installed, note that it will be
34 | downloaded and installed automatically as soon as you run setup.py.
35 | If you would rather install it manually, you may do so by following
36 | the instructions on this page:
37 |
38 | http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions
39 |
40 | 3) Build the C++ code, or install a binary distribution of protoc. If
41 | you install a binary distribution, make sure that it is the same
42 | version as this package. If in doubt, run:
43 |
44 | $ protoc --version
45 |
46 | 4) Run the tests:
47 |
48 | $ python setup.py test
49 |
50 | If some tests fail, this library may not work correctly on your
51 | system. Continue at your own risk.
52 |
53 | Please note that there is a known problem with some versions of
54 | Python on Cygwin which causes the tests to fail after printing the
55 | error: "sem_init: Resource temporarily unavailable". This appears
56 | to be a bug either in Cygwin or in Python:
57 | http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html
58 | We do not know if or when it might me fixed. We also do not know
59 | how likely it is that this bug will affect users in practice.
60 |
61 | 5) Install:
62 |
63 | $ python setup.py install
64 |
65 | This step may require superuser privileges.
66 |
67 | Usage
68 | =====
69 |
70 | The complete documentation for Protocol Buffers is available via the
71 | web at:
72 |
73 | http://code.google.com/apis/protocolbuffers/
74 |
--------------------------------------------------------------------------------
/compiler/java/src/test/java/com/google/protobuf/multiple_files_test.proto:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | // Author: kenton@google.com (Kenton Varda)
32 | //
33 | // A proto file which tests the java_multiple_files option.
34 |
35 |
36 | import "google/protobuf/unittest.proto";
37 |
38 | package protobuf_unittest;
39 |
40 | option java_multiple_files = true;
41 | option java_outer_classname = "MultipleFilesTestProto";
42 |
43 | message MessageWithNoOuter {
44 | message NestedMessage {
45 | optional int32 i = 1;
46 | }
47 | enum NestedEnum {
48 | BAZ = 3;
49 | }
50 | optional NestedMessage nested = 1;
51 | repeated TestAllTypes foreign = 2;
52 | optional NestedEnum nested_enum = 3;
53 | optional EnumWithNoOuter foreign_enum = 4;
54 | }
55 |
56 | enum EnumWithNoOuter {
57 | FOO = 1;
58 | BAR = 2;
59 | }
60 |
61 | service ServiceWithNoOuter {
62 | rpc Foo(MessageWithNoOuter) returns(TestAllTypes);
63 | }
64 |
65 | extend TestAllExtensions {
66 | optional int32 extension_with_outer = 1234567;
67 | }
68 |
--------------------------------------------------------------------------------
/compiler/src/google/protobuf/unittest_import.proto:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | // Author: kenton@google.com (Kenton Varda)
32 | // Based on original Protocol Buffers design by
33 | // Sanjay Ghemawat, Jeff Dean, and others.
34 | //
35 | // A proto file which is imported by unittest.proto to test importing.
36 |
37 |
38 | // We don't put this in a package within proto2 because we need to make sure
39 | // that the generated code doesn't depend on being in the proto2 namespace.
40 | // In test_util.h we do
41 | // "using namespace unittest_import = protobuf_unittest_import".
42 | package protobuf_unittest_import;
43 |
44 | option optimize_for = SPEED;
45 |
46 | // Excercise the java_package option.
47 | option java_package = "com.google.protobuf.test";
48 |
49 | // Do not set a java_outer_classname here to verify that Proto2 works without
50 | // one.
51 |
52 | message ImportMessage {
53 | optional int32 d = 1;
54 | }
55 |
56 | enum ImportEnum {
57 | IMPORT_FOO = 7;
58 | IMPORT_BAR = 8;
59 | IMPORT_BAZ = 9;
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/compiler/src/google/protobuf/io/package_info.h:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
31 | // Author: kenton@google.com (Kenton Varda)
32 | // Based on original Protocol Buffers design by
33 | // Sanjay Ghemawat, Jeff Dean, and others.
34 | //
35 | // This file exists solely to document the google::protobuf::io namespace.
36 | // It is not compiled into anything, but it may be read by an automated
37 | // documentation generator.
38 |
39 | namespace google {
40 |
41 | namespace protobuf {
42 |
43 | // Auxiliary classes used for I/O.
44 | //
45 | // The Protocol Buffer library uses the classes in this package to deal with
46 | // I/O and encoding/decoding raw bytes. Most users will not need to
47 | // deal with this package. However, users who want to adapt the system to
48 | // work with their own I/O abstractions -- e.g., to allow Protocol Buffers
49 | // to be read from a different kind of input stream without the need for a
50 | // temporary buffer -- should take a closer look.
51 | namespace io {}
52 |
53 | } // namespace protobuf
54 | } // namespace google
55 |
--------------------------------------------------------------------------------