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,8 +2,9 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef _CPPTOC_H
#define _CPPTOC_H
#ifndef CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_
#pragma once
#include "include/cef_base.h"
#include "include/capi/cef_base_capi.h"
@ -14,22 +15,19 @@
// implementation exists on this side of the DLL boundary but will have methods
// called from the other side of the DLL boundary.
template <class ClassName, class BaseName, class StructName>
class CefCppToC : public CefBase
{
public:
class CefCppToC : public CefBase {
public:
// Structure representation with pointer to the C++ class.
struct Struct
{
struct Struct {
StructName struct_;
CefCppToC<ClassName,BaseName,StructName>* class_;
CefCppToC<ClassName, BaseName, StructName>* class_;
};
// Use this method to retrieve the underlying class instance from our
// own structure when the structure is passed as the required first
// parameter of a C API function call. No explicit reference counting
// is done in this case.
static CefRefPtr<BaseName> Get(StructName* s)
{
static CefRefPtr<BaseName> Get(StructName* s) {
DCHECK(s);
// Cast our structure to the wrapper structure type.
@ -37,11 +35,10 @@ public:
// Return the underlying object instance.
return wrapperStruct->class_->GetClass();
}
// Use this method to create a wrapper structure for passing our class
// instance to the other side.
static StructName* Wrap(CefRefPtr<BaseName> c)
{
static StructName* Wrap(CefRefPtr<BaseName> c) {
if (!c.get())
return NULL;
@ -56,8 +53,7 @@ public:
// Use this method to retrieve the underlying class instance when receiving
// our wrapper structure back from the other side.
static CefRefPtr<BaseName> Unwrap(StructName* s)
{
static CefRefPtr<BaseName> Unwrap(StructName* s) {
if (!s)
return NULL;
@ -72,13 +68,12 @@ public:
return objectPtr;
}
CefCppToC(BaseName* cls)
: class_(cls)
{
explicit CefCppToC(BaseName* cls)
: class_(cls) {
DCHECK(cls);
struct_.class_ = this;
// zero the underlying structure and set base members
memset(&struct_.struct_, 0, sizeof(StructName));
struct_.struct_.base.size = sizeof(StructName);
@ -90,8 +85,7 @@ public:
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCppToC()
{
virtual ~CefCppToC() {
#ifndef NDEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
@ -106,13 +100,11 @@ public:
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class.
int AddRef()
{
int AddRef() {
UnderlyingAddRef();
return refct_.AddRef();
}
int Release()
{
int Release() {
UnderlyingRelease();
int retval = refct_.Release();
if (retval == 0)
@ -128,44 +120,41 @@ public:
#ifndef NDEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
static long DebugObjCt; // NOLINT(runtime/int)
#endif
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) {
DCHECK(base);
if(!base)
if (!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->AddRef();
}
static int CEF_CALLBACK struct_release(struct _cef_base_t* base)
{
static int CEF_CALLBACK struct_release(struct _cef_base_t* base) {
DCHECK(base);
if(!base)
if (!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->Release();
}
static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base)
{
static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) {
DCHECK(base);
if(!base)
if (!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt();
}
protected:
protected:
CefRefCount refct_;
Struct struct_;
BaseName* class_;
};
#endif // _CPPTOC_H
#endif // CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_