Home | History | Annotate | Download | only in cpp
      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 (a] google.com (Kenton Varda)
     32 //  Based on original Protocol Buffers design by
     33 //  Sanjay Ghemawat, Jeff Dean, and others.
     34 //
     35 // This file tests that various identifiers work as field and type names even
     36 // though the same identifiers are used internally by the C++ code generator.
     37 
     38 
     39 // We don't put this in a package within proto2 because we need to make sure
     40 // that the generated code doesn't depend on being in the proto2 namespace.
     41 package protobuf_unittest;
     42 
     43 // Test that fields can have names like "input" and "i" which are also used
     44 // internally by the code generator for local variables.
     45 message TestConflictingSymbolNames {
     46   message BuildDescriptors {}
     47   message TypeTraits {}
     48 
     49   optional int32 input = 1;
     50   optional int32 output = 2;
     51   optional string length = 3;
     52   repeated int32 i = 4;
     53   repeated string new_element = 5 [ctype=STRING_PIECE];
     54   optional int32 total_size = 6;
     55   optional int32 tag = 7;
     56 
     57   enum TestEnum { FOO = 1; }
     58   message Data1 { repeated int32 data = 1; }
     59   message Data2 { repeated TestEnum data = 1; }
     60   message Data3 { repeated string data = 1; }
     61   message Data4 { repeated Data4 data = 1; }
     62   message Data5 { repeated string data = 1 [ctype=STRING_PIECE]; }
     63   message Data6 { repeated string data = 1 [ctype=CORD]; }
     64 
     65   optional int32 source = 8;
     66   optional int32 value = 9;
     67   optional int32 file = 10;
     68   optional int32 from = 11;
     69   optional int32 handle_uninterpreted = 12;
     70   repeated int32 index = 13;
     71   optional int32 controller = 14;
     72   optional int32 already_here = 15;
     73 
     74   optional uint32 uint32 = 16;
     75   optional uint64 uint64 = 17;
     76   optional string string = 18;
     77   optional int32 memset = 19;
     78   optional int32 int32 = 20;
     79   optional int64 int64 = 21;
     80 
     81   optional uint32 cached_size = 22;
     82   optional uint32 extensions = 23;
     83   optional uint32 bit = 24;
     84   optional uint32 bits = 25;
     85   optional uint32 offsets = 26;
     86   optional uint32 reflection = 27;
     87 
     88   message Cord {}
     89   optional string some_cord = 28 [ctype=CORD];
     90 
     91   message StringPiece {}
     92   optional string some_string_piece = 29 [ctype=STRING_PIECE];
     93 
     94   // Some keywords.
     95   optional uint32 int = 30;
     96   optional uint32 friend = 31;
     97 
     98   // The generator used to #define a macro called "DO" inside the .cc file.
     99   message DO {}
    100   optional DO do = 32;
    101 
    102   extensions 1000 to max;
    103 }
    104 
    105 message DummyMessage {}
    106 
    107 service TestConflictingMethodNames {
    108   rpc Closure(DummyMessage) returns (DummyMessage);
    109 }
    110