cef/libcef_dll/ctocpp/ctocpp.h
Marshall Greenblatt 35e21da884 Add DLL build support and wrapper that allows clients to transparently switch between static and dynamic CEF builds.
- The libcef project now builds libcef_static.lib instead of libcef.lib.
- The libcef_dll project builds libcef.lib and libcef.dll.  This DLL exports the new CEF C API defined in cef_capi.h, cef_nplugin_capi.h, cef_string.h and cef_string_map.h.
- The libcef_dll_wrapper project builds libcef_dll_wrapper.lib.  This static library wraps the new C API calls with an implementation of the CEF C++ interface as defined in cef.h and cef_nplugin.h.
- The cefclient project now uses the DLL instead of the static library.
- Type definitions have been moved from cef.h to cef_types.h so that they can be shared by both cef.h and cef_capi.h.  This change required some enumeration member name modifications throughout the code base.
- Fixed variable naming inconsistencies.
- Added CefVariant::GetArraySize() method and _NPN_ArrayObjectGetVectorSize() function.
- Remove the ProjectSection(WebsiteProperties) sections from cef.sln to improve VS2005 performance.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@16 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2009-03-05 01:10:06 +00:00

65 lines
1.5 KiB
C++

// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef _CTOCPP_H
#define _CTOCPP_H
#include "cef.h"
#include "cef_capi.h"
#include "base/logging.h"
// Wrap a C structure with a C++ class.
template <class ClassName, class StructName>
class CefCToCpp : public CefThreadSafeBase<ClassName>
{
public:
CefCToCpp(StructName* str)
: struct_(str)
{
DCHECK(str);
}
virtual ~CefCToCpp()
{
}
// If returning the structure across the DLL boundary you should call
// UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of
// the DLL boundary, call Release() on the CefCppToC object.
StructName* GetStruct() { return struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapped structure.
virtual int AddRef()
{
UnderlyingAddRef();
return CefThreadSafeBase<ClassName>::AddRef();
}
virtual int Release()
{
UnderlyingRelease();
return CefThreadSafeBase<ClassName>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef()
{
if(!struct_->base.add_ref)
return 0;
return struct_->base.add_ref(&struct_->base);
}
int UnderlyingRelease()
{
if(!struct_->base.release)
return 0;
return struct_->base.release(&struct_->base);
}
protected:
StructName* struct_;
};
#endif // _CTOCPP_H