chromium/third_party/protobuf/src/google/protobuf/compiler/java/helpers.cc

// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// 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
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Author: [email protected] (Kenton Varda)
//  Based on original Protocol Buffers design by
//  Sanjay Ghemawat, Jeff Dean, and others.

#include <google/protobuf/compiler/java/helpers.h>

#include <algorithm>
#include <cstdint>
#include <limits>
#include <unordered_set>
#include <vector>

#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/name_resolver.h>
#include <google/protobuf/compiler/java/names.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/stubs/hash.h>  // for hash<T *>

// Must be last.
#include <google/protobuf/port_def.inc>

namespace google {
namespace protobuf {
namespace compiler {
namespace java {

WireFormat;
WireFormatLite;

const char kThickSeparator[] =;
const char kThinSeparator[] =;

namespace {

const char* kDefaultPackage =;

// Names that should be avoided (in UpperCamelCase format).
// Using them will cause the compiler to generate accessors whose names
// collide with methods defined in base classes.
// Keep this list in sync with specialFieldNames in
// java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java
const char* kForbiddenWordList[] =;

const std::unordered_set<std::string>* kReservedNames =;

bool IsForbidden(const std::string& field_name) {}

std::string FieldName(const FieldDescriptor* field) {}


}  // namespace

void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
                              const std::string& annotation_file) {}

void PrintEnumVerifierLogic(io::Printer* printer,
                            const FieldDescriptor* descriptor,
                            const std::map<std::string, std::string>& variables,
                            const char* var_name,
                            const char* terminating_string, bool enforce_lite) {}

std::string UnderscoresToCamelCase(const std::string& input,
                                   bool cap_next_letter) {}

std::string ToCamelCase(const std::string& input, bool lower_first) {}

char ToUpperCh(char ch) {}

char ToLowerCh(char ch) {}

std::string UnderscoresToCamelCase(const FieldDescriptor* field) {}

std::string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {}

std::string CapitalizedFieldName(const FieldDescriptor* field) {}

std::string UnderscoresToCamelCase(const MethodDescriptor* method) {}

std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {}

// Names that should be avoided as field names in Kotlin.
// All Kotlin hard keywords are in this list.
const std::unordered_set<std::string>* kKotlinForbiddenNames =;

bool IsForbiddenKotlin(const std::string& field_name) {}

std::string UniqueFileScopeIdentifier(const Descriptor* descriptor) {}

std::string CamelCaseFieldName(const FieldDescriptor* field) {}

std::string FileClassName(const FileDescriptor* file, bool immutable) {}

std::string FileJavaPackage(const FileDescriptor* file, bool immutable) {}

std::string FileJavaPackage(const FileDescriptor* file) {}

std::string JavaPackageToDir(std::string package_name) {}

std::string ClassName(const Descriptor* descriptor) {}

std::string ClassName(const EnumDescriptor* descriptor) {}

std::string ClassName(const ServiceDescriptor* descriptor) {}

std::string ClassName(const FileDescriptor* descriptor) {}


std::string ExtraMessageInterfaces(const Descriptor* descriptor) {}


std::string ExtraBuilderInterfaces(const Descriptor* descriptor) {}

std::string ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor) {}

std::string FieldConstantName(const FieldDescriptor* field) {}

FieldDescriptor::Type GetType(const FieldDescriptor* field) {}

JavaType GetJavaType(const FieldDescriptor* field) {}

const char* PrimitiveTypeName(JavaType type) {}

const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {}

const char* BoxedPrimitiveTypeName(JavaType type) {}

const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) {}

const char* KotlinTypeName(JavaType type) {}

std::string GetOneofStoredType(const FieldDescriptor* field) {}

const char* FieldTypeName(FieldDescriptor::Type field_type) {}

bool AllAscii(const std::string& text) {}

std::string DefaultValue(const FieldDescriptor* field, bool immutable,
                         ClassNameResolver* name_resolver) {}

bool IsDefaultValueJavaDefault(const FieldDescriptor* field) {}

bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) {}

const char* bit_masks[] =;

std::string GetBitFieldName(int index) {}

std::string GetBitFieldNameForBit(int bitIndex) {}

namespace {

std::string GenerateGetBitInternal(const std::string& prefix, int bitIndex) {}

std::string GenerateSetBitInternal(const std::string& prefix, int bitIndex) {}

}  // namespace

std::string GenerateGetBit(int bitIndex) {}

std::string GenerateSetBit(int bitIndex) {}

std::string GenerateClearBit(int bitIndex) {}

std::string GenerateGetBitFromLocal(int bitIndex) {}

std::string GenerateSetBitToLocal(int bitIndex) {}

std::string GenerateGetBitMutableLocal(int bitIndex) {}

std::string GenerateSetBitMutableLocal(int bitIndex) {}

bool IsReferenceType(JavaType type) {}

const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {}

// For encodings with fixed sizes, returns that size in bytes.  Otherwise
// returns -1.
int FixedSize(FieldDescriptor::Type type) {}

// Sort the fields of the given Descriptor by number into a new[]'d array
// and return it. The caller should delete the returned array.
const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {}

// Returns true if the message type has any required fields.  If it doesn't,
// we can optimize out calls to its isInitialized() method.
//
// already_seen is used to avoid checking the same type multiple times
// (and also to protect against recursion).
bool HasRequiredFields(const Descriptor* type,
                       std::unordered_set<const Descriptor*>* already_seen) {}

bool HasRequiredFields(const Descriptor* type) {}

bool HasRepeatedFields(const Descriptor* descriptor) {}

// Encode an unsigned 32-bit value into a sequence of UTF-16 characters.
//
// If the value is in [0x0000, 0xD7FF], we encode it with a single character
// with the same numeric value.
//
// If the value is larger than 0xD7FF, we encode its lowest 13 bits into a
// character in the range [0xE000, 0xFFFF] by combining these 13 bits with
// 0xE000 using logic-or. Then we shift the value to the right by 13 bits, and
// encode the remaining value by repeating this same process until we get to
// a value in [0x0000, 0xD7FF] where we will encode it using a character with
// the same numeric value.
//
// Note that we only use code points in [0x0000, 0xD7FF] and [0xE000, 0xFFFF].
// There will be no surrogate pairs in the encoded character sequence.
void WriteUInt32ToUtf16CharSequence(uint32_t number,
                                    std::vector<uint16_t>* output) {}

int GetExperimentalJavaFieldTypeForSingular(const FieldDescriptor* field) {}

int GetExperimentalJavaFieldTypeForRepeated(const FieldDescriptor* field) {}

int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor* field) {}

int GetExperimentalJavaFieldType(const FieldDescriptor* field) {}

// Escape a UTF-16 character to be embedded in a Java string.
void EscapeUtf16ToString(uint16_t code, std::string* output) {}

}  // namespace java
}  // namespace compiler
}  // namespace protobuf
}  // namespace google

#include <google/protobuf/port_undef.inc>