Skip to content

Commit

Permalink
Use clang-format-3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 18, 2015
1 parent cf1d6eb commit ecd4934
Show file tree
Hide file tree
Showing 81 changed files with 511 additions and 512 deletions.
12 changes: 2 additions & 10 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: true
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: None
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 80
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
Expand All @@ -31,7 +26,6 @@ IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
Expand All @@ -49,11 +43,9 @@ TabWidth: 8
UseTab: Never
BreakBeforeBraces: Attach
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
Expand Down
58 changes: 29 additions & 29 deletions src/compiler/cpp_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@
namespace grpc_cpp_generator {
namespace {

bool NoStreaming(const google::protobuf::MethodDescriptor* method) {
bool NoStreaming(const google::protobuf::MethodDescriptor *method) {
return !method->client_streaming() && !method->server_streaming();
}

bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor* method) {
bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor *method) {
return method->client_streaming() && !method->server_streaming();
}

bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor* method) {
bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor *method) {
return !method->client_streaming() && method->server_streaming();
}

bool BidiStreaming(const google::protobuf::MethodDescriptor* method) {
bool BidiStreaming(const google::protobuf::MethodDescriptor *method) {
return method->client_streaming() && method->server_streaming();
}

bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) {
bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor *file) {
for (int i = 0; i < file->service_count(); i++) {
for (int j = 0; j < file->service(i)->method_count(); j++) {
if (ClientOnlyStreaming(file->service(i)->method(j))) {
Expand All @@ -72,7 +72,7 @@ bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) {
return false;
}

bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor* file) {
bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor *file) {
for (int i = 0; i < file->service_count(); i++) {
for (int j = 0; j < file->service(i)->method_count(); j++) {
if (ServerOnlyStreaming(file->service(i)->method(j))) {
Expand All @@ -83,7 +83,7 @@ bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor* file) {
return false;
}

bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) {
bool HasBidiStreaming(const google::protobuf::FileDescriptor *file) {
for (int i = 0; i < file->service_count(); i++) {
for (int j = 0; j < file->service(i)->method_count(); j++) {
if (BidiStreaming(file->service(i)->method(j))) {
Expand All @@ -95,7 +95,7 @@ bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) {
}
} // namespace

std::string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) {
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor *file) {
std::string temp =
"#include \"grpc++/impl/internal_stub.h\"\n"
"#include \"grpc++/status.h\"\n"
Expand Down Expand Up @@ -131,9 +131,9 @@ std::string GetSourceIncludes() {
"#include \"grpc++/stream.h\"\n";
}

void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
std::map<std::string, std::string>* vars) {
void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
Expand All @@ -160,9 +160,9 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
}
}

void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
std::map<std::string, std::string>* vars) {
void PrintHeaderServerMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
Expand Down Expand Up @@ -194,9 +194,9 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
}
}

void PrintHeaderService(google::protobuf::io::Printer* printer,
const google::protobuf::ServiceDescriptor* service,
std::map<std::string, std::string>* vars) {
void PrintHeaderService(google::protobuf::io::Printer *printer,
const google::protobuf::ServiceDescriptor *service,
std::map<std::string, std::string> *vars) {
(*vars)["Service"] = service->name();

printer->Print(*vars,
Expand Down Expand Up @@ -241,7 +241,7 @@ void PrintHeaderService(google::protobuf::io::Printer* printer,
printer->Print("};\n");
}

std::string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
std::string GetHeaderServices(const google::protobuf::FileDescriptor *file) {
std::string output;
google::protobuf::io::StringOutputStream output_stream(&output);
google::protobuf::io::Printer printer(&output_stream, '$');
Expand All @@ -254,9 +254,9 @@ std::string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
return output;
}

void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
std::map<std::string, std::string>* vars) {
void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
Expand Down Expand Up @@ -312,9 +312,9 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
}
}

void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
std::map<std::string, std::string>* vars) {
void PrintSourceServerMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
Expand Down Expand Up @@ -362,9 +362,9 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
}
}

void PrintSourceService(google::protobuf::io::Printer* printer,
const google::protobuf::ServiceDescriptor* service,
std::map<std::string, std::string>* vars) {
void PrintSourceService(google::protobuf::io::Printer *printer,
const google::protobuf::ServiceDescriptor *service,
std::map<std::string, std::string> *vars) {
(*vars)["Service"] = service->name();
printer->Print(
*vars,
Expand Down Expand Up @@ -394,7 +394,7 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
"}\n");
printer->Print("service_ = new ::grpc::RpcService();\n");
for (int i = 0; i < service->method_count(); ++i) {
const google::protobuf::MethodDescriptor* method = service->method(i);
const google::protobuf::MethodDescriptor *method = service->method(i);
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
Expand Down Expand Up @@ -458,7 +458,7 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
printer->Print("}\n\n");
}

std::string GetSourceServices(const google::protobuf::FileDescriptor* file) {
std::string GetSourceServices(const google::protobuf::FileDescriptor *file) {
std::string output;
google::protobuf::io::StringOutputStream output_stream(&output);
google::protobuf::io::Printer printer(&output_stream, '$');
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/cpp_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ class FileDescriptor;
namespace grpc_cpp_generator {

// Return the includes needed for generated header file.
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor* file);
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor *file);

// Return the includes needed for generated source file.
std::string GetSourceIncludes();

// Return the services for generated header file.
std::string GetHeaderServices(const google::protobuf::FileDescriptor* file);
std::string GetHeaderServices(const google::protobuf::FileDescriptor *file);

// Return the services for generated source file.
std::string GetSourceServices(const google::protobuf::FileDescriptor* file);
std::string GetSourceServices(const google::protobuf::FileDescriptor *file);

} // namespace grpc_cpp_generator

Expand Down
16 changes: 8 additions & 8 deletions src/compiler/cpp_generator_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

namespace grpc_cpp_generator {

inline bool StripSuffix(std::string* filename, const std::string& suffix) {
inline bool StripSuffix(std::string *filename, const std::string &suffix) {
if (filename->length() >= suffix.length()) {
size_t suffix_pos = filename->length() - suffix.length();
if (filename->compare(suffix_pos, std::string::npos, suffix) == 0) {
Expand All @@ -60,8 +60,8 @@ inline std::string StripProto(std::string filename) {
return filename;
}

inline std::string StringReplace(std::string str, const std::string& from,
const std::string& to) {
inline std::string StringReplace(std::string str, const std::string &from,
const std::string &to) {
size_t pos = 0;

for (;;) {
Expand All @@ -76,22 +76,22 @@ inline std::string StringReplace(std::string str, const std::string& from,
return str;
}

inline std::string DotsToColons(const std::string& name) {
inline std::string DotsToColons(const std::string &name) {
return StringReplace(name, ".", "::");
}

inline std::string DotsToUnderscores(const std::string& name) {
inline std::string DotsToUnderscores(const std::string &name) {
return StringReplace(name, ".", "_");
}

inline std::string ClassName(const google::protobuf::Descriptor* descriptor,
inline std::string ClassName(const google::protobuf::Descriptor *descriptor,
bool qualified) {
// Find "outer", the descriptor of the top-level message in which
// "descriptor" is embedded.
const google::protobuf::Descriptor* outer = descriptor;
const google::protobuf::Descriptor *outer = descriptor;
while (outer->containing_type() != NULL) outer = outer->containing_type();

const std::string& outer_name = outer->full_name();
const std::string &outer_name = outer->full_name();
std::string inner_name = descriptor->full_name().substr(outer_name.size());

if (qualified) {
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/cpp_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
CppGrpcGenerator() {}
virtual ~CppGrpcGenerator() {}

virtual bool Generate(const google::protobuf::FileDescriptor* file,
const std::string& parameter,
google::protobuf::compiler::GeneratorContext* context,
std::string* error) const {
virtual bool Generate(const google::protobuf::FileDescriptor *file,
const std::string &parameter,
google::protobuf::compiler::GeneratorContext *context,
std::string *error) const {
if (file->options().cc_generic_services()) {
*error =
"cpp grpc proto compiler plugin does not work with generic "
Expand All @@ -81,17 +81,17 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {

private:
// Insert the given code into the given file at the given insertion point.
void Insert(google::protobuf::compiler::GeneratorContext* context,
const std::string& filename, const std::string& insertion_point,
const std::string& code) const {
void Insert(google::protobuf::compiler::GeneratorContext *context,
const std::string &filename, const std::string &insertion_point,
const std::string &code) const {
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->OpenForInsert(filename, insertion_point));
google::protobuf::io::CodedOutputStream coded_out(output.get());
coded_out.WriteRaw(code.data(), code.size());
}
};

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
CppGrpcGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}
10 changes: 5 additions & 5 deletions src/compiler/ruby_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ namespace grpc_ruby_generator {
namespace {

// Prints out the method using the ruby gRPC DSL.
void PrintMethod(const MethodDescriptor* method, const std::string& package,
Printer* out) {
void PrintMethod(const MethodDescriptor *method, const std::string &package,
Printer *out) {
std::string input_type = RubyTypeOf(method->input_type()->name(), package);
if (method->client_streaming()) {
input_type = "stream(" + input_type + ")";
Expand All @@ -75,8 +75,8 @@ void PrintMethod(const MethodDescriptor* method, const std::string& package,
}

// Prints out the service using the ruby gRPC DSL.
void PrintService(const ServiceDescriptor* service, const std::string& package,
Printer* out) {
void PrintService(const ServiceDescriptor *service, const std::string &package,
Printer *out) {
if (service->method_count() == 0) {
return;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ void PrintService(const ServiceDescriptor* service, const std::string& package,

} // namespace

std::string GetServices(const FileDescriptor* file) {
std::string GetServices(const FileDescriptor *file) {
std::string output;
StringOutputStream output_stream(&output);
Printer out(&output_stream, '$');
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/ruby_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FileDescriptor;

namespace grpc_ruby_generator {

std::string GetServices(const google::protobuf::FileDescriptor* file);
std::string GetServices(const google::protobuf::FileDescriptor *file);

} // namespace grpc_ruby_generator

Expand Down
6 changes: 3 additions & 3 deletions src/compiler/ruby_generator_helpers-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

namespace grpc_ruby_generator {

inline bool ServicesFilename(const google::protobuf::FileDescriptor* file,
std::string* file_name_or_error) {
inline bool ServicesFilename(const google::protobuf::FileDescriptor *file,
std::string *file_name_or_error) {
// Get output file name.
static const unsigned proto_suffix_length = 6; // length of ".proto"
if (file->name().size() > proto_suffix_length &&
Expand All @@ -58,7 +58,7 @@ inline bool ServicesFilename(const google::protobuf::FileDescriptor* file,
}

inline std::string MessagesRequireName(
const google::protobuf::FileDescriptor* file) {
const google::protobuf::FileDescriptor *file) {
return Replace(file->name(), ".proto", "");
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/ruby_generator_map-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace grpc_ruby_generator {
// Converts an initializer list of the form { key0, value0, key1, value1, ... }
// into a map of key* to value*. Is merely a readability helper for later code.
inline std::map<std::string, std::string> ListToDict(
const initializer_list<std::string>& values) {
const initializer_list<std::string> &values) {
if (values.size() % 2 != 0) {
// MOE: insert std::cerr << "Not every 'key' has a value in `values`."
// << std::endl;
Expand Down
Loading

0 comments on commit ecd4934

Please sign in to comment.