Make CEF compliant with Google/Chromium style (issue #473).

- Add a new check_style tool based on Google's cpplint that can be used to verify compliance of pending changes and specific files/directories.
- Update existing CEF source code to be compliant with the style requirements.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@463 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-01-09 23:46:23 +00:00
parent 9cc61f448b
commit 1073577d03
558 changed files with 9002 additions and 10977 deletions

View File

@ -2,18 +2,19 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "binding_test.h"
#include "cefclient/binding_test.h"
#include <sstream>
#include <string>
#include <vector>
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_v8.h"
#include <sstream>
// Implementation of the V8 handler class for the "window.cef_test.Dump"
// function.
class ClientV8FunctionHandler : public CefV8Handler
{
public:
class ClientV8FunctionHandler : public CefV8Handler {
public:
ClientV8FunctionHandler() {}
virtual ~ClientV8FunctionHandler() {}
@ -23,17 +24,14 @@ public:
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) OVERRIDE
{
if(name == "Dump")
{
CefString& exception) OVERRIDE {
if (name == "Dump") {
// The "Dump" function will return a human-readable dump of the input
// arguments.
std::stringstream stream;
size_t i;
for(i = 0; i < arguments.size(); ++i)
{
for (i = 0; i < arguments.size(); ++i) {
stream << "arg[" << i << "] = ";
PrintValue(arguments[i], stream, 0);
stream << "\n";
@ -41,15 +39,13 @@ public:
retval = CefV8Value::CreateString(stream.str());
return true;
}
else if(name == "Call")
{
} else if (name == "Call") {
// The "Call" function will execute a function to get an object and then
// return the result of calling a function belonging to that object. The
// first arument is the function that will return an object and the second
// argument is the function that will be called on that returned object.
int argSize = arguments.size();
if(argSize < 2 || !arguments[0]->IsFunction()
if (argSize < 2 || !arguments[0]->IsFunction()
|| !arguments[1]->IsString())
return false;
@ -68,7 +64,7 @@ public:
return false;
// Verify that the returned value is an object.
if(!objectPtr.get() || !objectPtr->IsObject())
if (!objectPtr.get() || !objectPtr->IsObject())
return false;
// Retrieve the member function specified by name in the second argument
@ -76,13 +72,13 @@ public:
CefRefPtr<CefV8Value> funcPtr =
objectPtr->GetValue(arguments[1]->GetStringValue());
// Verify that the returned value is a function.
if(!funcPtr.get() || !funcPtr->IsFunction())
if (!funcPtr.get() || !funcPtr->IsFunction())
return false;
// Pass any additional arguments on to the member function.
for(int i = 2; i < argSize; ++i)
for (int i = 2; i < argSize; ++i)
argList.push_back(arguments[i]);
// Execute the member function.
result = funcPtr->ExecuteFunction(arguments[0], argList, retval,
exceptionPtr, false);
@ -95,40 +91,39 @@ public:
// Simple function for formatted output of a V8 value.
void PrintValue(CefRefPtr<CefV8Value> value, std::stringstream &stream,
int indent)
{
int indent) {
std::stringstream indent_stream;
for(int i = 0; i < indent; ++i)
for (int i = 0; i < indent; ++i)
indent_stream << " ";
std::string indent_str = indent_stream.str();
if(value->IsUndefined())
if (value->IsUndefined())
stream << "(undefined)";
else if(value->IsNull())
else if (value->IsNull())
stream << "(null)";
else if(value->IsBool())
else if (value->IsBool())
stream << "(bool) " << (value->GetBoolValue() ? "true" : "false");
else if(value->IsInt())
else if (value->IsInt())
stream << "(int) " << value->GetIntValue();
else if(value->IsDouble())
else if (value->IsDouble())
stream << "(double) " << value->GetDoubleValue();
else if(value->IsString())
else if (value->IsString())
stream << "(string) " << std::string(value->GetStringValue());
else if(value->IsFunction())
else if (value->IsFunction())
stream << "(function) " << std::string(value->GetFunctionName());
else if(value->IsArray()) {
else if (value->IsArray()) {
stream << "(array) [";
int len = value->GetArrayLength();
for(int i = 0; i < len; ++i) {
for (int i = 0; i < len; ++i) {
stream << "\n " << indent_str.c_str() << i << " = ";
PrintValue(value->GetValue(i), stream, indent+1);
}
stream << "\n" << indent_str.c_str() << "]";
} else if(value->IsObject()) {
} else if (value->IsObject()) {
stream << "(object) [";
std::vector<CefString> keys;
if(value->GetKeys(keys)) {
for(size_t i = 0; i < keys.size(); ++i) {
if (value->GetKeys(keys)) {
for (size_t i = 0; i < keys.size(); ++i) {
stream << "\n " << indent_str.c_str() << keys[i].c_str() << " = ";
PrintValue(value->GetValue(keys[i]), stream, indent+1);
}
@ -143,8 +138,7 @@ public:
void InitBindingTest(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Value> object)
{
CefRefPtr<CefV8Value> object) {
// Create the new V8 object.
CefRefPtr<CefV8Value> testObjPtr = CefV8Value::CreateObject(NULL, NULL);
// Add the new V8 object to the global window object with the name
@ -164,8 +158,7 @@ void InitBindingTest(CefRefPtr<CefBrowser> browser,
V8_PROPERTY_ATTRIBUTE_NONE);
}
void RunBindingTest(CefRefPtr<CefBrowser> browser)
{
void RunBindingTest(CefRefPtr<CefBrowser> browser) {
std::string html =
"<html><body>ClientV8FunctionHandler says:<br><pre>"
"<script language=\"JavaScript\">"
@ -178,7 +171,8 @@ void RunBindingTest(CefRefPtr<CefBrowser> browser)
" var obj = {};"
" (function() {"
" obj.GetMessage = function(a) {"
" return 'Calling a function with value '+a+' on a user object succeeded.';"
" return 'Calling a function with value '+a+' on a user object "
"succeeded.';"
" };"
" })();"
" return obj;"