- Add the CEF translator tool for generating the C API header and cpptoc/ctocpp wrapper files.

- Update to files generated by the CEF translator tool.  This introduces minor changes in cef.h and cef_capi.h for naming and translation consistency.
- C API global function names that were previously in the cef_create_classname*() format are now in the cef_classname_create*() format.
- cef_frame_t::get_frame_names() now returns void instead of size_t.
- cef_frame_t::execute_javascript() has been renamed to cef_frame_t::execute_java_script().
- The 'arguments' attribute of CefV8Handler::Execute() and CefV8Value::ExecuteFunction() is now const.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@30 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2009-06-20 22:09:28 +00:00
parent d953faf7f8
commit 8a04c0f0c1
64 changed files with 6830 additions and 3579 deletions

View File

@ -0,0 +1,143 @@
// 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 _BASE_CPPTOC_H
#define _BASE_CPPTOC_H
#include "cef.h"
#include "cef_capi.h"
#include "../cef_logging.h"
// CefCppToC implementation for CefBase.
class CefBaseCppToC : public CefThreadSafeBase<CefBase>
{
public:
// 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<CefBase> Get(cef_base_t* s)
{
// Cast our structure to the wrapper structure type.
CefBaseCppToC::Struct* wrapperStruct =
reinterpret_cast<CefBaseCppToC::Struct*>(s);
// 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 cef_base_t* Wrap(CefRefPtr<CefBase> c)
{
// Wrap our object with the CefCppToC class.
CefBaseCppToC* wrapper = new CefBaseCppToC(c);
// Add a reference to our wrapper object that will be released once our
// structure arrives on the other side.
wrapper->AddRef();
// Return the structure pointer that can now be passed to the other side.
return wrapper->GetStruct();
}
// Use this method to retrieve the underlying class instance when receiving
// our wrapper structure back from the other side.
static CefRefPtr<CefBase> Unwrap(cef_base_t* s)
{
// Cast our structure to the wrapper structure type.
CefBaseCppToC::Struct* wrapperStruct =
reinterpret_cast<CefBaseCppToC::Struct*>(s);
// Add the underlying object instance to a smart pointer.
CefRefPtr<CefBase> objectPtr(wrapperStruct->class_->GetClass());
// Release the reference to our wrapper object that was added before the
// structure was passed back to us.
wrapperStruct->class_->Release();
// Return the underlying object instance.
return objectPtr;
}
// Structure representation with pointer to the C++ class.
struct Struct
{
cef_base_t struct_;
CefBaseCppToC* class_;
};
CefBaseCppToC(CefBase* cls)
: class_(cls)
{
DCHECK(cls);
struct_.class_ = this;
// zero the underlying structure and set base members
memset(&struct_.struct_, 0, sizeof(cef_base_t));
struct_.struct_.size = sizeof(cef_base_t);
struct_.struct_.add_ref = struct_add_ref;
struct_.struct_.release = struct_release;
struct_.struct_.get_refct = struct_get_refct;
}
virtual ~CefBaseCppToC() {}
CefBase* GetClass() { return class_; }
// If returning the structure across the DLL boundary you should call
// AddRef() on this CefCppToC object. On the other side of the DLL boundary,
// call UnderlyingRelease() on the wrapping CefCToCpp object.
cef_base_t* GetStruct() { return &struct_.struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class.
virtual int AddRef()
{
UnderlyingAddRef();
return CefThreadSafeBase<CefBase>::AddRef();
}
virtual int Release()
{
UnderlyingRelease();
return CefThreadSafeBase<CefBase>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); }
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{
DCHECK(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)
{
DCHECK(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)
{
DCHECK(base);
if(!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt();
}
protected:
Struct struct_;
CefBase* class_;
};
#endif // _BASE_CPPTOC_H

View File

@ -1,176 +1,231 @@
// 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.
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/browser_cpptoc.h"
#include "cpptoc/frame_cpptoc.h"
#include "ctocpp/handler_ctocpp.h"
int CEF_CALLBACK browser_can_go_back(cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return 0;
return CefBrowserCppToC::Get(browser)->CanGoBack();
}
void CEF_CALLBACK browser_go_back(cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return;
CefBrowserCppToC::Get(browser)->GoBack();
}
// GLOBAL FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK browser_can_go_forward(cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return 0;
return CefBrowserCppToC::Get(browser)->CanGoForward();
}
void CEF_CALLBACK browser_go_forward(cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return;
CefBrowserCppToC::Get(browser)->GoForward();
}
void CEF_CALLBACK browser_reload(cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return;
CefBrowserCppToC::Get(browser)->Reload();
}
void CEF_CALLBACK browser_stop_load(cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return;
CefBrowserCppToC::Get(browser)->StopLoad();
}
void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* browser, int enable)
CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup,
struct _cef_handler_t* handler, const wchar_t* url)
{
DCHECK(browser);
if(!browser)
return;
CefBrowserCppToC::Get(browser)->SetFocus(enable ? true : false);
DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo;
if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url)
urlStr = url;
return CefBrowser::CreateBrowser(wi, popup, handlerPtr, urlStr);
}
cef_window_handle_t CEF_CALLBACK browser_get_window_handle(cef_browser_t* browser)
CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo,
int popup, struct _cef_handler_t* handler, const wchar_t* url)
{
DCHECK(browser);
if(!browser)
return NULL;
return CefBrowserCppToC::Get(browser)->GetWindowHandle();
DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo;
if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url)
urlStr = url;
CefRefPtr<CefBrowser> browserPtr(
CefBrowser::CreateBrowserSync(wi, popup, handlerPtr, urlStr));
if(browserPtr.get())
return CefBrowserCppToC::Wrap(browserPtr);
return NULL;
}
int CEF_CALLBACK browser_is_popup(cef_browser_t* browser)
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t* self)
{
DCHECK(browser);
if(!browser)
return 0;
return CefBrowserCppToC::Get(browser)->IsPopup();
DCHECK(self);
if(!self)
return 0;
return CefBrowserCppToC::Get(self)->CanGoBack();
}
cef_handler_t* CEF_CALLBACK browser_get_handler(cef_browser_t* browser)
void CEF_CALLBACK browser_go_back(struct _cef_browser_t* self)
{
DCHECK(browser);
if(!browser)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
DCHECK(self);
if(!self)
return;
CefBrowserCppToC::Get(self)->GoBack();
}
int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefBrowserCppToC::Get(self)->CanGoForward();
}
void CEF_CALLBACK browser_go_forward(struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return;
CefBrowserCppToC::Get(self)->GoForward();
}
void CEF_CALLBACK browser_reload(struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return;
CefBrowserCppToC::Get(self)->Reload();
}
void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return;
CefBrowserCppToC::Get(self)->StopLoad();
}
void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* self, int enable)
{
DCHECK(self);
if(!self)
return;
CefBrowserCppToC::Get(self)->SetFocus(enable ? true : false);
}
cef_window_handle_t CEF_CALLBACK browser_get_window_handle(
struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return NULL;
return CefBrowserCppToC::Get(self)->GetWindowHandle();
}
int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefBrowserCppToC::Get(self)->IsPopup();
}
struct _cef_handler_t* CEF_CALLBACK browser_get_handler(
struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefHandler> handlerPtr = browserPtr->GetHandler();
if(handlerPtr.get())
return CefHandlerCToCpp::Unwrap(handlerPtr);
return NULL;
}
struct _cef_frame_t* CEF_CALLBACK browser_get_main_frame(
struct _cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
}
struct _cef_frame_t* CEF_CALLBACK browser_get_main_frame(
struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetMainFrame();
if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr);
return NULL;
}
return NULL;
}
struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame(
struct _cef_browser_t* browser)
{
DCHECK(browser);
if(!browser)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame(
struct _cef_browser_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFocusedFrame();
if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr);
return NULL;
}
return NULL;
}
struct _cef_frame_t* CEF_CALLBACK browser_get_frame(
struct _cef_browser_t* browser, const wchar_t* name)
{
DCHECK(browser);
if(!browser)
return NULL;
std::wstring nameStr;
if(name)
nameStr = name;
if(nameStr.empty())
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
struct _cef_frame_t* CEF_CALLBACK browser_get_frame(struct _cef_browser_t* self,
const wchar_t* name)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring nameStr;
if(name)
nameStr = name;
if(nameStr.empty())
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(nameStr);
if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr);
return NULL;
}
size_t CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* browser,
cef_string_list_t list)
{
DCHECK(browser);
DCHECK(list);
if(!browser || !list)
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
std::vector<std::wstring> stringList;
browserPtr->GetFrameNames(stringList);
size_t size = stringList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(list, stringList[i].c_str());
return size;
return NULL;
}
CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
: CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>(cls)
{
void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self,
cef_string_list_t names)
{
DCHECK(self);
DCHECK(names);
if(!self || !names)
return;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
std::vector<std::wstring> stringList;
browserPtr->GetFrameNames(stringList);
size_t size = stringList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(names, stringList[i].c_str());
}
// CONSTRUCTOR - Do not edit by hand.
CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
: CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>(cls)
{
struct_.struct_.can_go_back = browser_can_go_back;
struct_.struct_.go_back = browser_go_back;
struct_.struct_.can_go_forward = browser_can_go_forward;
@ -180,13 +235,14 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
struct_.struct_.set_focus = browser_set_focus;
struct_.struct_.get_window_handle = browser_get_window_handle;
struct_.struct_.is_popup = browser_is_popup;
struct_.struct_.get_handler = browser_get_handler;
struct_.struct_.get_main_frame = browser_get_main_frame;
struct_.struct_.get_focused_frame = browser_get_focused_frame;
struct_.struct_.get_frame = browser_get_frame;
struct_.struct_.get_frame_names = browser_get_frame_names;
}
struct_.struct_.get_handler = browser_get_handler;
struct_.struct_.get_main_frame = browser_get_main_frame;
struct_.struct_.get_focused_frame = browser_get_focused_frame;
struct_.struct_.get_frame = browser_get_frame;
struct_.struct_.get_frame_names = browser_get_frame_names;
}
#ifdef _DEBUG
long CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>::DebugObjCt = 0;
#endif

View File

@ -1,29 +1,34 @@
// 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 _BROWSER_CPPTOC_H
#define _BROWSER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _BROWSER_CPPTOC_H
#define _BROWSER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefBrowserCppToC
: public CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>
{
public:
CefBrowserCppToC(CefBrowser* cls);
virtual ~CefBrowserCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _BROWSER_CPPTOC_H
// Wrap a C++ browser class with a C browser structure.
// This class may be instantiated and accessed DLL-side only.
class CefBrowserCppToC
: public CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>
{
public:
CefBrowserCppToC(CefBrowser* cls);
virtual ~CefBrowserCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _BROWSER_CPPTOC_H

View File

@ -1,290 +1,160 @@
// 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 _CPPTOC_H
#define _CPPTOC_H
#include "cef.h"
// 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 _CPPTOC_H
#define _CPPTOC_H
#include "cef.h"
#include "cef_capi.h"
#include "../cef_logging.h"
// Wrap a C++ class with a C structure. This is used when the class
// implementation exists on this side of the DLL boundary but will have methods
// called from the other side of the DLL boundary.
#include "../cef_logging.h"
// Wrap a C++ class with a C structure. This is used when the class
// 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 CefThreadSafeBase<CefBase>
{
public:
// 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)
{
// Cast our structure to the wrapper structure type.
ClassName::Struct* wrapperStruct =
reinterpret_cast<ClassName::Struct*>(s);
// 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)
{
// Wrap our object with the CefCppToC class.
public:
// 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)
{
// Cast our structure to the wrapper structure type.
ClassName::Struct* wrapperStruct =
reinterpret_cast<ClassName::Struct*>(s);
// 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)
{
// Wrap our object with the CefCppToC class.
ClassName* wrapper = new ClassName(c);
// Add a reference to our wrapper object that will be released once our
// structure arrives on the other side.
wrapper->AddRef();
// Return the structure pointer that can now be passed to the other side.
return wrapper->GetStruct();
}
// 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)
{
// Cast our structure to the wrapper structure type.
wrapper->AddRef();
// Return the structure pointer that can now be passed to the other side.
return wrapper->GetStruct();
}
// 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)
{
// Cast our structure to the wrapper structure type.
ClassName::Struct* wrapperStruct =
reinterpret_cast<ClassName::Struct*>(s);
// Add the underlying object instance to a smart pointer.
CefRefPtr<BaseName> objectPtr(wrapperStruct->class_->GetClass());
// Release the reference to our wrapper object that was added before the
// structure was passed back to us.
wrapperStruct->class_->Release();
// Return the underlying object instance.
return objectPtr;
}
// Structure representation with pointer to the C++ class.
reinterpret_cast<ClassName::Struct*>(s);
// Add the underlying object instance to a smart pointer.
CefRefPtr<BaseName> objectPtr(wrapperStruct->class_->GetClass());
// Release the reference to our wrapper object that was added before the
// structure was passed back to us.
wrapperStruct->class_->Release();
// Return the underlying object instance.
return objectPtr;
}
// Structure representation with pointer to the C++ class.
struct Struct
{
StructName struct_;
CefCppToC<ClassName,BaseName,StructName>* class_;
};
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);
};
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);
struct_.struct_.base.add_ref = struct_add_ref;
struct_.struct_.base.release = struct_release;
struct_.struct_.base.get_refct = struct_get_refct;
#ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCppToC()
{
#ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
}
BaseName* GetClass() { return class_; }
// If returning the structure across the DLL boundary you should call
// AddRef() on this CefCppToC object. On the other side of the DLL boundary,
// call UnderlyingRelease() on the wrapping CefCToCpp object.
StructName* GetStruct() { return &struct_.struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class.
struct_.struct_.base.release = struct_release;
struct_.struct_.base.get_refct = struct_get_refct;
#ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCppToC()
{
#ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
}
BaseName* GetClass() { return class_; }
// If returning the structure across the DLL boundary you should call
// AddRef() on this CefCppToC object. On the other side of the DLL boundary,
// call UnderlyingRelease() on the wrapping CefCToCpp object.
StructName* GetStruct() { return &struct_.struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class.
virtual int AddRef()
{
UnderlyingAddRef();
return CefThreadSafeBase<CefBase>::AddRef();
}
virtual int Release()
{
virtual int Release()
{
UnderlyingRelease();
return CefThreadSafeBase<CefBase>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); }
#ifdef _DEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
#endif
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{
DCHECK(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)
{
DCHECK(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)
{
DCHECK(base);
if(!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt();
}
protected:
return CefThreadSafeBase<CefBase>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); }
#ifdef _DEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
#endif
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{
DCHECK(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)
{
DCHECK(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)
{
DCHECK(base);
if(!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt();
}
protected:
Struct struct_;
BaseName* class_;
BaseName* class_;
};
// CefCppToC implementation for CefBase.
class CefBaseCppToC : public CefThreadSafeBase<CefBase>
{
public:
// 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<CefBase> Get(cef_base_t* s)
{
// Cast our structure to the wrapper structure type.
CefBaseCppToC::Struct* wrapperStruct =
reinterpret_cast<CefBaseCppToC::Struct*>(s);
// 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 cef_base_t* Wrap(CefRefPtr<CefBase> c)
{
// Wrap our object with the CefCppToC class.
CefBaseCppToC* wrapper = new CefBaseCppToC(c);
// Add a reference to our wrapper object that will be released once our
// structure arrives on the other side.
wrapper->AddRef();
// Return the structure pointer that can now be passed to the other side.
return wrapper->GetStruct();
}
// Use this method to retrieve the underlying class instance when receiving
// our wrapper structure back from the other side.
static CefRefPtr<CefBase> Unwrap(cef_base_t* s)
{
// Cast our structure to the wrapper structure type.
CefBaseCppToC::Struct* wrapperStruct =
reinterpret_cast<CefBaseCppToC::Struct*>(s);
// Add the underlying object instance to a smart pointer.
CefRefPtr<CefBase> objectPtr(wrapperStruct->class_->GetClass());
// Release the reference to our wrapper object that was added before the
// structure was passed back to us.
wrapperStruct->class_->Release();
// Return the underlying object instance.
return objectPtr;
}
// Structure representation with pointer to the C++ class.
struct Struct
{
cef_base_t struct_;
CefBaseCppToC* class_;
};
CefBaseCppToC(CefBase* cls)
: class_(cls)
{
DCHECK(cls);
struct_.class_ = this;
// zero the underlying structure and set base members
memset(&struct_.struct_, 0, sizeof(cef_base_t));
struct_.struct_.size = sizeof(cef_base_t);
struct_.struct_.add_ref = struct_add_ref;
struct_.struct_.release = struct_release;
struct_.struct_.get_refct = struct_get_refct;
}
virtual ~CefBaseCppToC() {}
CefBase* GetClass() { return class_; }
// If returning the structure across the DLL boundary you should call
// AddRef() on this CefCppToC object. On the other side of the DLL boundary,
// call UnderlyingRelease() on the wrapping CefCToCpp object.
cef_base_t* GetStruct() { return &struct_.struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class.
virtual int AddRef()
{
UnderlyingAddRef();
return CefThreadSafeBase<CefBase>::AddRef();
}
virtual int Release()
{
UnderlyingRelease();
return CefThreadSafeBase<CefBase>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); }
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{
DCHECK(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)
{
DCHECK(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)
{
DCHECK(base);
if(!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt();
}
protected:
Struct struct_;
CefBase* class_;
};
#endif // _CPPTOC_H
#endif // _CPPTOC_H

View File

@ -1,246 +1,254 @@
// 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.
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/frame_cpptoc.h"
#include "cpptoc/request_cpptoc.h"
#include "cpptoc/stream_cpptoc.h"
#include "cpptoc/stream_reader_cpptoc.h"
void CEF_CALLBACK frame_undo(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Undo();
}
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK frame_redo(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Redo();
}
void CEF_CALLBACK frame_cut(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Cut();
}
void CEF_CALLBACK frame_copy(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Copy();
}
void CEF_CALLBACK frame_paste(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Paste();
}
void CEF_CALLBACK frame_delete(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Delete();
}
void CEF_CALLBACK frame_select_all(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->SelectAll();
}
void CEF_CALLBACK frame_print(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->Print();
}
void CEF_CALLBACK frame_view_source(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return;
CefFrameCppToC::Get(frame)->ViewSource();
}
cef_string_t CEF_CALLBACK frame_get_source(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return NULL;
std::wstring sourceStr = CefFrameCppToC::Get(frame)->GetSource();
if(!sourceStr.empty())
return cef_string_alloc(sourceStr.c_str());
return NULL;
}
cef_string_t CEF_CALLBACK frame_get_text(cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return NULL;
std::wstring textStr = CefFrameCppToC::Get(frame)->GetText();
if(!textStr.empty())
return cef_string_alloc(textStr.c_str());
return NULL;
}
void CEF_CALLBACK frame_load_request(cef_frame_t* frame,
cef_request_t* request)
{
DCHECK(frame);
DCHECK(request);
if(!frame || !request)
return;
CefRefPtr<CefRequest> requestPtr = CefRequestCppToC::Unwrap(request);
CefFrameCppToC::Get(frame)->LoadRequest(requestPtr);
}
void CEF_CALLBACK frame_load_url(cef_frame_t* frame, const wchar_t* url)
{
DCHECK(frame);
if(!frame)
return;
std::wstring urlStr;
if(url)
urlStr = url;
CefFrameCppToC::Get(frame)->LoadURL(urlStr);
}
void CEF_CALLBACK frame_load_string(cef_frame_t* frame,
const wchar_t* string,
const wchar_t* url)
{
DCHECK(frame);
if(!frame)
return;
std::wstring stringStr, urlStr;
if(string)
stringStr = string;
if(url)
urlStr = url;
CefFrameCppToC::Get(frame)->LoadString(stringStr, urlStr);
}
void CEF_CALLBACK frame_load_stream(cef_frame_t* frame,
cef_stream_reader_t* stream,
const wchar_t* url)
{
DCHECK(frame);
DCHECK(stream);
if(!frame || !stream)
return;
CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream);
std::wstring urlStr;
if(url)
urlStr = url;
CefFrameCppToC::Get(frame)->LoadStream(streamPtr, urlStr);
}
void CEF_CALLBACK frame_execute_javascript(cef_frame_t* frame,
const wchar_t* jsCode,
const wchar_t* scriptUrl,
int startLine)
{
DCHECK(frame);
if(!frame)
return;
std::wstring jsCodeStr, scriptUrlStr;
if(jsCode)
jsCodeStr = jsCode;
if(scriptUrl)
scriptUrlStr = scriptUrl;
CefFrameCppToC::Get(frame)->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
startLine);
}
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return 0;
return CefFrameCppToC::Get(frame)->IsMain();
}
int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return 0;
return CefFrameCppToC::Get(frame)->IsFocused();
}
cef_string_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* frame)
{
DCHECK(frame);
if(!frame)
return 0;
std::wstring nameStr = CefFrameCppToC::Get(frame)->GetName();
if(!nameStr.empty())
return cef_string_alloc(nameStr.c_str());
return NULL;
}
cef_string_t CEF_CALLBACK frame_get_url(cef_frame_t* frame)
void CEF_CALLBACK frame_undo(struct _cef_frame_t* self)
{
DCHECK(frame);
if(!frame)
return NULL;
std::wstring urlStr = CefFrameCppToC::Get(frame)->GetURL();
if(!urlStr.empty())
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Undo();
}
void CEF_CALLBACK frame_redo(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Redo();
}
void CEF_CALLBACK frame_cut(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Cut();
}
void CEF_CALLBACK frame_copy(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Copy();
}
void CEF_CALLBACK frame_paste(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Paste();
}
void CEF_CALLBACK frame_del(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Delete();
}
void CEF_CALLBACK frame_select_all(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->SelectAll();
}
void CEF_CALLBACK frame_print(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->Print();
}
void CEF_CALLBACK frame_view_source(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return;
CefFrameCppToC::Get(self)->ViewSource();
}
cef_string_t CEF_CALLBACK frame_get_source(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring sourceStr = CefFrameCppToC::Get(self)->GetSource();
if(!sourceStr.empty())
return cef_string_alloc(sourceStr.c_str());
return NULL;
}
cef_string_t CEF_CALLBACK frame_get_text(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring textStr = CefFrameCppToC::Get(self)->GetText();
if(!textStr.empty())
return cef_string_alloc(textStr.c_str());
return NULL;
}
void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self,
struct _cef_request_t* request)
{
DCHECK(self);
DCHECK(request);
if(!self || !request)
return;
CefRefPtr<CefRequest> requestPtr = CefRequestCppToC::Unwrap(request);
CefFrameCppToC::Get(self)->LoadRequest(requestPtr);
}
void CEF_CALLBACK frame_load_url(struct _cef_frame_t* self, const wchar_t* url)
{
DCHECK(self);
if(!self)
return;
std::wstring urlStr;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadURL(urlStr);
}
void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self,
const wchar_t* string, const wchar_t* url)
{
DCHECK(self);
if(!self)
return;
std::wstring stringStr, urlStr;
if(string)
stringStr = string;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadString(stringStr, urlStr);
}
void CEF_CALLBACK frame_load_stream(struct _cef_frame_t* self,
struct _cef_stream_reader_t* stream, const wchar_t* url)
{
DCHECK(self);
DCHECK(stream);
if(!self || !stream)
return;
CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream);
std::wstring urlStr;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadStream(streamPtr, urlStr);
}
void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self,
const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine)
{
DCHECK(self);
if(!self)
return;
std::wstring jsCodeStr, scriptUrlStr;
if(jsCode)
jsCodeStr = jsCode;
if(scriptUrl)
scriptUrlStr = scriptUrl;
CefFrameCppToC::Get(self)->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
startLine);
}
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefFrameCppToC::Get(self)->IsMain();
}
int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefFrameCppToC::Get(self)->IsFocused();
}
cef_string_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return 0;
std::wstring nameStr = CefFrameCppToC::Get(self)->GetName();
if(!nameStr.empty())
return cef_string_alloc(nameStr.c_str());
return NULL;
}
cef_string_t CEF_CALLBACK frame_get_url(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring urlStr = CefFrameCppToC::Get(self)->GetURL();
if(!urlStr.empty())
return cef_string_alloc(urlStr.c_str());
return NULL;
}
CefFrameCppToC::CefFrameCppToC(CefFrame* cls)
: CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>(cls)
{
// CONSTRUCTOR - Do not edit by hand.
CefFrameCppToC::CefFrameCppToC(CefFrame* cls)
: CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>(cls)
{
struct_.struct_.undo = frame_undo;
struct_.struct_.redo = frame_redo;
struct_.struct_.cut = frame_cut;
struct_.struct_.copy = frame_copy;
struct_.struct_.paste = frame_paste;
struct_.struct_.del = frame_delete;
struct_.struct_.del = frame_del;
struct_.struct_.select_all = frame_select_all;
struct_.struct_.print = frame_print;
struct_.struct_.view_source = frame_view_source;
@ -250,13 +258,14 @@ CefFrameCppToC::CefFrameCppToC(CefFrame* cls)
struct_.struct_.load_url = frame_load_url;
struct_.struct_.load_string = frame_load_string;
struct_.struct_.load_stream = frame_load_stream;
struct_.struct_.execute_javascript = frame_execute_javascript;
struct_.struct_.is_main = frame_is_main;
struct_.struct_.is_focused = frame_is_focused;
struct_.struct_.get_name = frame_get_name;
struct_.struct_.get_url = frame_get_url;
}
struct_.struct_.execute_java_script = frame_execute_java_script;
struct_.struct_.is_main = frame_is_main;
struct_.struct_.is_focused = frame_is_focused;
struct_.struct_.get_name = frame_get_name;
struct_.struct_.get_url = frame_get_url;
}
#ifdef _DEBUG
long CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>::DebugObjCt = 0;
#endif

View File

@ -1,29 +1,34 @@
// 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 _FRAME_CPPTOC_H
#define _FRAME_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _FRAME_CPPTOC_H
#define _FRAME_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefFrameCppToC
: public CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>
{
public:
CefFrameCppToC(CefFrame* cls);
virtual ~CefFrameCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _FRAME_CPPTOC_H
// Wrap a C++ frame class with a C frame structure.
// This class may be instantiated and accessed DLL-side only.
class CefFrameCppToC
: public CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>
{
public:
CefFrameCppToC(CefFrame* cls);
virtual ~CefFrameCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _FRAME_CPPTOC_H

View File

@ -1,486 +1,497 @@
// 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.
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/handler_cpptoc.h"
#include "ctocpp/browser_ctocpp.h"
#include "ctocpp/frame_ctocpp.h"
#include "ctocpp/request_ctocpp.h"
#include "ctocpp/stream_ctocpp.h"
#include "ctocpp/stream_reader_ctocpp.h"
#include "ctocpp/v8value_ctocpp.h"
#include "transfer_util.h"
#include "../transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
struct _cef_handler_t* handler, cef_browser_t* parentBrowser,
cef_window_info_t* windowInfo, int popup,
struct _cef_handler_t** newHandler, cef_string_t* url)
{
DCHECK(handler);
DCHECK(windowInfo);
DCHECK(newHandler && *newHandler);
DCHECK(url);
if(!handler || !windowInfo || !newHandler || !*newHandler || !url)
return RV_CONTINUE;
CefWindowInfo wndInfo(*windowInfo);
// |newHandler| will start off pointing to the current handler.
CefRefPtr<CefHandler> handlerPtr = CefHandlerCppToC::Unwrap(*newHandler);
CefHandler* origHandler = handlerPtr.get();
// |parentBrowser| will be NULL if this is a top-level browser window.
CefRefPtr<CefBrowser> browserPtr;
if(parentBrowser)
browserPtr = CefBrowserCToCpp::Wrap(parentBrowser);
std::wstring urlStr;
if(*url)
urlStr = *url;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleBeforeCreated(
browserPtr, wndInfo, popup, handlerPtr, urlStr);
transfer_string_contents(urlStr, url);
if(handlerPtr.get() != origHandler) {
// The handler has been changed.
*newHandler = CefHandlerCppToC::Wrap(handlerPtr);
}
// WindowInfo may or may not have changed.
*windowInfo = wndInfo;
#ifdef WIN32
// The m_windowName must be duplicated since it's a cef_string_t
if(windowInfo->m_windowName)
windowInfo->m_windowName = cef_string_alloc(windowInfo->m_windowName);
#endif
return rv;
}
struct _cef_handler_t* self, cef_browser_t* parentBrowser,
cef_window_info_t* windowInfo, int popup, struct _cef_handler_t** handler,
cef_string_t* url)
{
DCHECK(self);
DCHECK(windowInfo);
DCHECK(handler && *handler);
DCHECK(url);
if(!self || !windowInfo || !handler || !*handler || !url)
return RV_CONTINUE;
CefWindowInfo wndInfo(*windowInfo);
// |newHandler| will start off pointing to the current handler.
CefRefPtr<CefHandler> handlerPtr = CefHandlerCppToC::Unwrap(*handler);
CefHandler* origHandler = handlerPtr.get();
// |parentBrowser| will be NULL if this is a top-level browser window.
CefRefPtr<CefBrowser> browserPtr;
if(parentBrowser)
browserPtr = CefBrowserCToCpp::Wrap(parentBrowser);
std::wstring urlStr;
if(*url)
urlStr = *url;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated(
browserPtr, wndInfo, popup, handlerPtr, urlStr);
transfer_string_contents(urlStr, url);
if(handlerPtr.get() != origHandler) {
// The handler has been changed.
*handler = CefHandlerCppToC::Wrap(handlerPtr);
}
// WindowInfo may or may not have changed.
*windowInfo = wndInfo;
#ifdef WIN32
// The m_windowName must be duplicated since it's a cef_string_t
if(windowInfo->m_windowName)
windowInfo->m_windowName = cef_string_alloc(windowInfo->m_windowName);
#endif
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_after_created(
struct _cef_handler_t* handler, cef_browser_t* browser)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleAfterCreated(
CefBrowserCToCpp::Wrap(browser));
struct _cef_handler_t* self, cef_browser_t* browser)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleAfterCreated(
CefBrowserCToCpp::Wrap(browser));
}
enum cef_retval_t CEF_CALLBACK handler_handle_address_change(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* url)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
if(!handler || !browser || !frame)
return RV_CONTINUE;
std::wstring urlStr;
if(url)
urlStr = url;
return CefHandlerCppToC::Get(handler)->HandleAddressChange(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), urlStr);
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* url)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
if(!self || !browser || !frame)
return RV_CONTINUE;
std::wstring urlStr;
if(url)
urlStr = url;
return CefHandlerCppToC::Get(self)->HandleAddressChange(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), urlStr);
}
enum cef_retval_t CEF_CALLBACK handler_handle_title_change(
struct _cef_handler_t* handler, cef_browser_t* browser,
const wchar_t* title)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
std::wstring titleStr;
if(title)
titleStr = title;
return CefHandlerCppToC::Get(handler)->HandleTitleChange(
CefBrowserCToCpp::Wrap(browser), titleStr);
struct _cef_handler_t* self, cef_browser_t* browser, const wchar_t* title)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
std::wstring titleStr;
if(title)
titleStr = title;
return CefHandlerCppToC::Get(self)->HandleTitleChange(
CefBrowserCToCpp::Wrap(browser), titleStr);
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_browse(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
struct _cef_request_t* request, cef_handler_navtype_t navType,
int isRedirect)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
DCHECK(request);
if(!handler || !browser || !request || !frame)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleBeforeBrowse(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefRequestCToCpp::Wrap(request), navType, (isRedirect ? true : false));
int isRedirect)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(request);
if(!self || !browser || !request || !frame)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleBeforeBrowse(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefRequestCToCpp::Wrap(request), navType, (isRedirect ? true : false));
}
enum cef_retval_t CEF_CALLBACK handler_handle_load_start(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
CefRefPtr<CefFrame> framePtr;
if(frame)
framePtr = CefFrameCToCpp::Wrap(frame);
return CefHandlerCppToC::Get(handler)->HandleLoadStart(
CefBrowserCToCpp::Wrap(browser), framePtr);
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
CefRefPtr<CefFrame> framePtr;
if(frame)
framePtr = CefFrameCToCpp::Wrap(frame);
return CefHandlerCppToC::Get(self)->HandleLoadStart(
CefBrowserCToCpp::Wrap(browser), framePtr);
}
enum cef_retval_t CEF_CALLBACK handler_handle_load_end(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
CefRefPtr<CefFrame> framePtr;
if(frame)
framePtr = CefFrameCToCpp::Wrap(frame);
return CefHandlerCppToC::Get(handler)->HandleLoadEnd(
CefBrowserCToCpp::Wrap(browser), framePtr);
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
CefRefPtr<CefFrame> framePtr;
if(frame)
framePtr = CefFrameCToCpp::Wrap(frame);
return CefHandlerCppToC::Get(self)->HandleLoadEnd(
CefBrowserCToCpp::Wrap(browser), framePtr);
}
enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
cef_handler_errorcode_t errorCode, const wchar_t* failedUrl,
cef_string_t* errorText)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
DCHECK(errorText);
if(!handler || !browser || !errorText || !frame)
return RV_CONTINUE;
std::wstring failedUrlStr, errorTextStr;
if(failedUrl)
failedUrlStr = failedUrl;
if(*errorText)
errorTextStr = *errorText;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleLoadError(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode,
failedUrlStr, errorTextStr);
transfer_string_contents(errorTextStr, errorText);
return rv;
cef_string_t* errorText)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(errorText);
if(!self || !browser || !errorText || !frame)
return RV_CONTINUE;
std::wstring failedUrlStr, errorTextStr;
if(failedUrl)
failedUrlStr = failedUrl;
if(*errorText)
errorTextStr = *errorText;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleLoadError(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode,
failedUrlStr, errorTextStr);
transfer_string_contents(errorTextStr, errorText);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
struct _cef_handler_t* handler, cef_browser_t* browser,
struct _cef_handler_t* self, cef_browser_t* browser,
struct _cef_request_t* request, cef_string_t* redirectUrl,
struct _cef_stream_reader_t** resourceStream, cef_string_t* mimeType,
int loadFlags)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(redirectUrl);
DCHECK(resourceStream);
DCHECK(mimeType);
if(!handler || !browser || !redirectUrl || !resourceStream || !mimeType)
return RV_CONTINUE;
std::wstring redirectUrlStr, mimeTypeStr;
CefRefPtr<CefStreamReader> streamPtr;
if(*redirectUrl)
redirectUrlStr = *redirectUrl;
if(*mimeType)
mimeTypeStr = *mimeType;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->
HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser),
CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr,
loadFlags);
transfer_string_contents(redirectUrlStr, redirectUrl);
transfer_string_contents(mimeTypeStr, mimeType);
if(streamPtr.get())
*resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr);
return rv;
int loadFlags)
{
DCHECK(self);
DCHECK(browser);
DCHECK(redirectUrl);
DCHECK(resourceStream);
DCHECK(mimeType);
if(!self || !browser || !redirectUrl || !resourceStream || !mimeType)
return RV_CONTINUE;
std::wstring redirectUrlStr, mimeTypeStr;
CefRefPtr<CefStreamReader> streamPtr;
if(*redirectUrl)
redirectUrlStr = *redirectUrl;
if(*mimeType)
mimeTypeStr = *mimeType;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser),
CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr,
loadFlags);
transfer_string_contents(redirectUrlStr, redirectUrl);
transfer_string_contents(mimeTypeStr, mimeType);
if(streamPtr.get())
*resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_menu(
struct _cef_handler_t* handler, cef_browser_t* browser,
const cef_handler_menuinfo_t* menuInfo)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(menuInfo);
if(!handler || !browser || !menuInfo)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleBeforeMenu(
CefBrowserCToCpp::Wrap(browser), *menuInfo);
struct _cef_handler_t* self, cef_browser_t* browser,
const cef_handler_menuinfo_t* menuInfo)
{
DCHECK(self);
DCHECK(browser);
DCHECK(menuInfo);
if(!self || !browser || !menuInfo)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleBeforeMenu(
CefBrowserCToCpp::Wrap(browser), *menuInfo);
}
enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label(
struct _cef_handler_t* handler, cef_browser_t* browser,
cef_handler_menuid_t menuId, cef_string_t* label)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(label);
if(!handler || !browser || !label)
return RV_CONTINUE;
std::wstring labelStr;
if(*label)
labelStr = *label;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleGetMenuLabel(
CefBrowserCToCpp::Wrap(browser), menuId, labelStr);
transfer_string_contents(labelStr, label);
return rv;
struct _cef_handler_t* self, cef_browser_t* browser,
cef_handler_menuid_t menuId, cef_string_t* label)
{
DCHECK(self);
DCHECK(browser);
DCHECK(label);
if(!self || !browser || !label)
return RV_CONTINUE;
std::wstring labelStr;
if(*label)
labelStr = *label;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleGetMenuLabel(
CefBrowserCToCpp::Wrap(browser), menuId, labelStr);
transfer_string_contents(labelStr, label);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_menu_action(
struct _cef_handler_t* handler, cef_browser_t* browser,
cef_handler_menuid_t menuId)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleMenuAction(
CefBrowserCToCpp::Wrap(browser), menuId);
struct _cef_handler_t* self, cef_browser_t* browser,
cef_handler_menuid_t menuId)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleMenuAction(
CefBrowserCToCpp::Wrap(browser), menuId);
}
enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
cef_print_info_t* printInfo, const wchar_t* url, const wchar_t* title,
int currentPage, int maxPages, cef_string_t* topLeft,
cef_string_t* topCenter, cef_string_t* topRight,
cef_string_t* bottomLeft, cef_string_t* bottomCenter,
cef_string_t* bottomRight)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
DCHECK(printInfo);
DCHECK(topLeft && topCenter && topRight);
DCHECK(bottomLeft && bottomCenter && bottomRight);
if(!handler || !browser || !frame || !printInfo || !topLeft || !topCenter
|| !topRight || !bottomLeft || !bottomCenter || !bottomRight)
return RV_CONTINUE;
std::wstring urlStr, titleStr;
std::wstring topLeftStr, topCenterStr, topRightStr;
std::wstring bottomLeftStr, bottomCenterStr, bottomRightStr;
CefPrintInfo info = *printInfo;
if(url)
urlStr = url;
if(title)
titleStr = title;
if(*topLeft)
topLeftStr = *topLeft;
if(*topCenter)
topCenterStr = *topCenter;
if(*topRight)
topRightStr = *topRight;
if(*bottomLeft)
bottomLeftStr = *bottomLeft;
if(*bottomCenter)
bottomCenterStr = *bottomCenter;
if(*bottomRight)
bottomRightStr = *bottomRight;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->
HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame), info, urlStr, titleStr, currentPage,
maxPages, topLeftStr, topCenterStr, topRightStr, bottomLeftStr,
bottomCenterStr, bottomRightStr);
transfer_string_contents(topLeftStr, topLeft);
transfer_string_contents(topCenterStr, topCenter);
transfer_string_contents(topRightStr, topRight);
transfer_string_contents(bottomLeftStr, bottomLeft);
transfer_string_contents(bottomCenterStr, bottomCenter);
transfer_string_contents(bottomRightStr, bottomRight);
return rv;
cef_string_t* topCenter, cef_string_t* topRight, cef_string_t* bottomLeft,
cef_string_t* bottomCenter, cef_string_t* bottomRight)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(printInfo);
DCHECK(topLeft && topCenter && topRight);
DCHECK(bottomLeft && bottomCenter && bottomRight);
if(!self || !browser || !frame || !printInfo || !topLeft || !topCenter
|| !topRight || !bottomLeft || !bottomCenter || !bottomRight)
return RV_CONTINUE;
std::wstring urlStr, titleStr;
std::wstring topLeftStr, topCenterStr, topRightStr;
std::wstring bottomLeftStr, bottomCenterStr, bottomRightStr;
CefPrintInfo info = *printInfo;
if(url)
urlStr = url;
if(title)
titleStr = title;
if(*topLeft)
topLeftStr = *topLeft;
if(*topCenter)
topCenterStr = *topCenter;
if(*topRight)
topRightStr = *topRight;
if(*bottomLeft)
bottomLeftStr = *bottomLeft;
if(*bottomCenter)
bottomCenterStr = *bottomCenter;
if(*bottomRight)
bottomRightStr = *bottomRight;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame), info, urlStr, titleStr, currentPage,
maxPages, topLeftStr, topCenterStr, topRightStr, bottomLeftStr,
bottomCenterStr, bottomRightStr);
transfer_string_contents(topLeftStr, topLeft);
transfer_string_contents(topCenterStr, topCenter);
transfer_string_contents(topRightStr, topRight);
transfer_string_contents(bottomLeftStr, bottomLeft);
transfer_string_contents(bottomCenterStr, bottomCenter);
transfer_string_contents(bottomRightStr, bottomRight);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
if(!handler || !browser || !frame)
return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
return CefHandlerCppToC::Get(handler)->HandleJSAlert(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr);
}
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
if(!self || !browser || !frame)
return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
return CefHandlerCppToC::Get(self)->HandleJSAlert(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr);
}
enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message, int* retval)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
DCHECK(retval);
if(!handler || !browser || !retval || !frame)
return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleJSConfirm(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
ret);
*retval = (ret ? 1 : 0);
return rv;
}
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message, int* retval)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(retval);
if(!self || !browser || !retval || !frame)
return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSConfirm(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
ret);
*retval = (ret ? 1 : 0);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message, const wchar_t* defaultValue, int* retval,
cef_string_t* result)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
DCHECK(retval);
DCHECK(result);
if(!handler || !browser || !frame || !retval || !result)
return RV_CONTINUE;
std::wstring messageStr, defaultValueStr, resultStr;
if(message)
messageStr = message;
if(defaultValue)
defaultValueStr = defaultValue;
if(*result)
resultStr = *result;
bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleJSPrompt(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
defaultValueStr, ret, resultStr);
*retval = (ret ? 1 : 0);
transfer_string_contents(resultStr, result);
return rv;
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message, const wchar_t* defaultValue, int* retval,
cef_string_t* result)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(retval);
DCHECK(result);
if(!self || !browser || !frame || !retval || !result)
return RV_CONTINUE;
std::wstring messageStr, defaultValueStr, resultStr;
if(message)
messageStr = message;
if(defaultValue)
defaultValueStr = defaultValue;
if(*result)
resultStr = *result;
bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
defaultValueStr, ret, resultStr);
*retval = (ret ? 1 : 0);
transfer_string_contents(resultStr, result);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_window_close(
struct _cef_handler_t* handler, cef_browser_t* browser)
struct _cef_handler_t* self, cef_browser_t* browser)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleBeforeWindowClose(
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleBeforeWindowClose(
CefBrowserCToCpp::Wrap(browser));
}
enum cef_retval_t CEF_CALLBACK handler_handle_take_focus(
struct _cef_handler_t* handler, cef_browser_t* browser, int reverse)
struct _cef_handler_t* self, cef_browser_t* browser, int reverse)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleTakeFocus(
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleTakeFocus(
CefBrowserCToCpp::Wrap(browser), (reverse ? true : false));
}
enum cef_retval_t CEF_CALLBACK handler_handle_jsbinding(
struct _cef_handler_t* handler, cef_browser_t* browser,
cef_frame_t* frame, struct _cef_v8value_t* object)
enum cef_retval_t CEF_CALLBACK handler_handle_jsbinding(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
struct _cef_v8value_t* object)
{
DCHECK(handler);
DCHECK(browser);
DCHECK(frame);
DCHECK(object);
if(!handler || !browser || !frame || !object)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleJSBinding(
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(object);
if(!self || !browser || !frame || !object)
return RV_CONTINUE;
return CefHandlerCppToC::Get(self)->HandleJSBinding(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefV8ValueCToCpp::Wrap(object));
}
enum cef_retval_t CEF_CALLBACK handler_handle_set_focus(
struct _cef_handler_t* handler, cef_browser_t* browser, int isWidget)
struct _cef_handler_t* self, cef_browser_t* browser, int isWidget)
{
DCHECK(handler);
DCHECK(self);
DCHECK(browser);
if(!handler || !browser)
if(!self || !browser)
return RV_CONTINUE;
return CefHandlerCppToC::Get(handler)->HandleSetFocus(
return CefHandlerCppToC::Get(self)->HandleSetFocus(
CefBrowserCToCpp::Wrap(browser), isWidget);
}
CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
: CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>(cls)
{
struct_.struct_.handle_before_created = handler_handle_before_created;
struct_.struct_.handle_after_created = handler_handle_after_created;
struct_.struct_.handle_address_change = handler_handle_address_change;
struct_.struct_.handle_title_change = handler_handle_title_change;
struct_.struct_.handle_before_browse = handler_handle_before_browse;
struct_.struct_.handle_load_start = handler_handle_load_start;
struct_.struct_.handle_load_end = handler_handle_load_end;
struct_.struct_.handle_load_error = handler_handle_load_error;
struct_.struct_.handle_before_resource_load =
handler_handle_before_resource_load;
struct_.struct_.handle_before_menu = handler_handle_before_menu;
struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label;
struct_.struct_.handle_menu_action = handler_handle_menu_action;
struct_.struct_.handle_print_header_footer =
handler_handle_print_header_footer;
struct_.struct_.handle_jsalert = handler_handle_jsalert;
struct_.struct_.handle_jsconfirm = handler_handle_jsconfirm;
struct_.struct_.handle_jsprompt = handler_handle_jsprompt;
struct_.struct_.handle_before_window_close =
handler_handle_before_window_close;
struct_.struct_.handle_take_focus = handler_handle_take_focus;
struct_.struct_.handle_jsbinding = handler_handle_jsbinding;
// CONSTRUCTOR - Do not edit by hand.
CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
: CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>(cls)
{
struct_.struct_.handle_before_created = handler_handle_before_created;
struct_.struct_.handle_after_created = handler_handle_after_created;
struct_.struct_.handle_address_change = handler_handle_address_change;
struct_.struct_.handle_title_change = handler_handle_title_change;
struct_.struct_.handle_before_browse = handler_handle_before_browse;
struct_.struct_.handle_load_start = handler_handle_load_start;
struct_.struct_.handle_load_end = handler_handle_load_end;
struct_.struct_.handle_load_error = handler_handle_load_error;
struct_.struct_.handle_before_resource_load =
handler_handle_before_resource_load;
struct_.struct_.handle_before_menu = handler_handle_before_menu;
struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label;
struct_.struct_.handle_menu_action = handler_handle_menu_action;
struct_.struct_.handle_print_header_footer =
handler_handle_print_header_footer;
struct_.struct_.handle_jsalert = handler_handle_jsalert;
struct_.struct_.handle_jsconfirm = handler_handle_jsconfirm;
struct_.struct_.handle_jsprompt = handler_handle_jsprompt;
struct_.struct_.handle_before_window_close =
handler_handle_before_window_close;
struct_.struct_.handle_take_focus = handler_handle_take_focus;
struct_.struct_.handle_jsbinding = handler_handle_jsbinding;
struct_.struct_.handle_set_focus = handler_handle_set_focus;
}
#ifdef _DEBUG
long CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>::DebugObjCt = 0;
#endif

View File

@ -1,29 +1,34 @@
// 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 _HANDLER_CPPTOC_H
#define _HANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _HANDLER_CPPTOC_H
#define _HANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefHandlerCppToC
: public CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>
{
public:
CefHandlerCppToC(CefHandler* cls);
virtual ~CefHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _HANDLER_CPPTOC_H
// Wrap a C++ handler class with a C handler structure.
// This class may be instantiated and accessed wrapper-side only.
class CefHandlerCppToC
: public CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>
{
public:
CefHandlerCppToC(CefHandler* cls);
virtual ~CefHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _HANDLER_CPPTOC_H

View File

@ -0,0 +1,107 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/post_data_cpptoc.h"
#include "cpptoc/post_data_element_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_post_data_t* cef_post_data_create()
{
CefRefPtr<CefPostData> impl = CefPostData::CreatePostData();
if(impl.get())
return CefPostDataCppToC::Wrap(impl);
return NULL;
}
// MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK post_data_get_element_count(struct _cef_post_data_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefPostDataCppToC::Get(self)->GetElementCount();
}
struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_elements(
struct _cef_post_data_t* self, int elementIndex)
{
DCHECK(self);
if(!self)
return NULL;
CefPostData::ElementVector elements;
CefPostDataCppToC::Get(self)->GetElements(elements);
if(elementIndex < 0 || elementIndex >= (int)elements.size())
return NULL;
return CefPostDataElementCppToC::Wrap(elements[elementIndex]);
}
int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* self,
struct _cef_post_data_element_t* element)
{
DCHECK(self);
DCHECK(element);
if(!self || !element)
return 0;
CefRefPtr<CefPostDataElement> selfElementPtr =
CefPostDataElementCppToC::Unwrap(element);
return CefPostDataCppToC::Get(self)->RemoveElement(selfElementPtr);
}
int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* self,
struct _cef_post_data_element_t* element)
{
DCHECK(self);
DCHECK(element);
if(!self || !element)
return 0;
CefRefPtr<CefPostDataElement> selfElementPtr =
CefPostDataElementCppToC::Unwrap(element);
return CefPostDataCppToC::Get(self)->AddElement(selfElementPtr);
}
void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* self)
{
DCHECK(self);
if(!self)
return;
CefPostDataCppToC::Get(self)->RemoveElements();
}
// CONSTRUCTOR - Do not edit by hand.
CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
: CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>(cls)
{
struct_.struct_.get_element_count = post_data_get_element_count;
struct_.struct_.get_elements = post_data_get_elements;
struct_.struct_.remove_element = post_data_remove_element;
struct_.struct_.add_element = post_data_add_element;
struct_.struct_.remove_elements = post_data_remove_elements;
}
#ifdef _DEBUG
long CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,34 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _POSTDATA_CPPTOC_H
#define _POSTDATA_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefPostDataCppToC
: public CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>
{
public:
CefPostDataCppToC(CefPostData* cls);
virtual ~CefPostDataCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _POSTDATA_CPPTOC_H

View File

@ -0,0 +1,129 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/post_data_element_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create()
{
CefRefPtr<CefPostDataElement> impl =
CefPostDataElement::CreatePostDataElement();
if(impl.get())
return CefPostDataElementCppToC::Wrap(impl);
return NULL;
}
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK post_data_element_set_to_empty(
struct _cef_post_data_element_t* self)
{
DCHECK(self);
if(!self)
return;
CefPostDataElementCppToC::Get(self)->SetToEmpty();
}
void CEF_CALLBACK post_data_element_set_to_file(
struct _cef_post_data_element_t* self, const wchar_t* fileName)
{
DCHECK(self);
if(!self)
return;
std::wstring fileNameStr;
if(fileName)
fileNameStr = fileName;
CefPostDataElementCppToC::Get(self)->SetToFile(fileNameStr);
}
void CEF_CALLBACK post_data_element_set_to_bytes(
struct _cef_post_data_element_t* self, size_t size, const void* bytes)
{
DCHECK(self);
if(!self)
return;
CefPostDataElementCppToC::Get(self)->SetToBytes(size, bytes);
}
enum cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
struct _cef_post_data_element_t* self)
{
DCHECK(self);
if(!self)
return PDE_TYPE_EMPTY;
return CefPostDataElementCppToC::Get(self)->GetType();
}
cef_string_t CEF_CALLBACK post_data_element_get_file(
struct _cef_post_data_element_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring fileNameStr =
CefPostDataElementCppToC::Get(self)->GetFile();
if(!fileNameStr.empty())
return cef_string_alloc(fileNameStr.c_str());
return NULL;
}
size_t CEF_CALLBACK post_data_element_get_bytes_count(
struct _cef_post_data_element_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefPostDataElementCppToC::Get(self)->GetBytesCount();
}
size_t CEF_CALLBACK post_data_element_get_bytes(
struct _cef_post_data_element_t* self, size_t size, void *bytes)
{
DCHECK(self);
if(!self)
return 0;
return CefPostDataElementCppToC::Get(self)->GetBytes(size, bytes);
}
// CONSTRUCTOR - Do not edit by hand.
CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
: CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>(cls)
{
struct_.struct_.set_to_empty = post_data_element_set_to_empty;
struct_.struct_.set_to_file = post_data_element_set_to_file;
struct_.struct_.set_to_bytes = post_data_element_set_to_bytes;
struct_.struct_.get_type = post_data_element_get_type;
struct_.struct_.get_file = post_data_element_get_file;
struct_.struct_.get_bytes_count = post_data_element_get_bytes_count;
struct_.struct_.get_bytes = post_data_element_get_bytes;
}
#ifdef _DEBUG
long CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,35 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _POSTDATAELEMENT_CPPTOC_H
#define _POSTDATAELEMENT_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefPostDataElementCppToC
: public CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>
{
public:
CefPostDataElementCppToC(CefPostDataElement* cls);
virtual ~CefPostDataElementCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _POSTDATAELEMENT_CPPTOC_H

View File

@ -1,126 +1,147 @@
// 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.
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/post_data_cpptoc.h"
#include "cpptoc/request_cpptoc.h"
#include "transfer_util.h"
#include "../transfer_util.h"
cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* request)
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_request_t* cef_request_create()
{
DCHECK(request);
if(!request)
return NULL;
std::wstring urlStr = CefRequestCppToC::Get(request)->GetURL();
CefRefPtr<CefRequest> impl = CefRequest::CreateRequest();
if(impl.get())
return CefRequestCppToC::Wrap(impl);
return NULL;
}
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring urlStr = CefRequestCppToC::Get(self)->GetURL();
if(!urlStr.empty())
return cef_string_alloc(urlStr.c_str());
return NULL;
}
void CEF_CALLBACK request_set_url(struct _cef_request_t* request,
const wchar_t* url)
void CEF_CALLBACK request_set_url(struct _cef_request_t* self,
const wchar_t* url)
{
DCHECK(request);
if(!request)
return;
std::wstring urlStr;
if(url)
urlStr = url;
CefRequestCppToC::Get(request)->SetURL(urlStr);
DCHECK(self);
if(!self)
return;
std::wstring urlStr;
if(url)
urlStr = url;
CefRequestCppToC::Get(self)->SetURL(urlStr);
}
cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* request)
cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* self)
{
DCHECK(request);
if(!request)
return NULL;
std::wstring methodStr = CefRequestCppToC::Get(request)->GetMethod();
DCHECK(self);
if(!self)
return NULL;
std::wstring methodStr = CefRequestCppToC::Get(self)->GetMethod();
if(!methodStr.empty())
return cef_string_alloc(methodStr.c_str());
return NULL;
}
void CEF_CALLBACK request_set_method(struct _cef_request_t* request,
const wchar_t* method)
void CEF_CALLBACK request_set_method(struct _cef_request_t* self,
const wchar_t* method)
{
DCHECK(request);
if(!request)
return;
std::wstring methodStr;
if(method)
methodStr = method;
CefRequestCppToC::Get(request)->SetMethod(methodStr);
DCHECK(self);
if(!self)
return;
std::wstring methodStr;
if(method)
methodStr = method;
CefRequestCppToC::Get(self)->SetMethod(methodStr);
}
struct _cef_post_data_t* CEF_CALLBACK request_get_post_data(
struct _cef_request_t* request)
struct _cef_request_t* self)
{
DCHECK(request);
if(!request)
return NULL;
DCHECK(self);
if(!self)
return NULL;
CefRefPtr<CefPostData> postDataPtr =
CefRequestCppToC::Get(request)->GetPostData();
CefRequestCppToC::Get(self)->GetPostData();
if(!postDataPtr.get())
return NULL;
return CefPostDataCppToC::Wrap(postDataPtr);
}
void CEF_CALLBACK request_set_post_data(struct _cef_request_t* request,
struct _cef_post_data_t* postData)
void CEF_CALLBACK request_set_post_data(struct _cef_request_t* self,
struct _cef_post_data_t* postData)
{
DCHECK(request);
if(!request)
return;
DCHECK(self);
if(!self)
return;
CefRefPtr<CefPostData> postDataPtr;
if(postData)
postDataPtr = CefPostDataCppToC::Unwrap(postData);
CefRequestCppToC::Get(request)->SetPostData(postDataPtr);
CefRequestCppToC::Get(self)->SetPostData(postDataPtr);
}
void CEF_CALLBACK request_get_header_map(struct _cef_request_t* request,
cef_string_map_t headerMap)
void CEF_CALLBACK request_get_header_map(struct _cef_request_t* self,
cef_string_map_t headerMap)
{
DCHECK(request);
if(!request)
return;
DCHECK(self);
if(!self)
return;
CefRequest::HeaderMap map;
CefRequestCppToC::Get(request)->GetHeaderMap(map);
CefRequestCppToC::Get(self)->GetHeaderMap(map);
transfer_string_map_contents(map, headerMap);
}
void CEF_CALLBACK request_set_header_map(struct _cef_request_t* request,
cef_string_map_t headerMap)
void CEF_CALLBACK request_set_header_map(struct _cef_request_t* self,
cef_string_map_t headerMap)
{
DCHECK(request);
if(!request)
return;
DCHECK(self);
if(!self)
return;
CefRequest::HeaderMap map;
if(headerMap)
transfer_string_map_contents(headerMap, map);
CefRequestCppToC::Get(request)->SetHeaderMap(map);
CefRequestCppToC::Get(self)->SetHeaderMap(map);
}
void CEF_CALLBACK request_set(struct _cef_request_t* request,
const wchar_t* url, const wchar_t* method,
struct _cef_post_data_t* postData,
cef_string_map_t headerMap)
void CEF_CALLBACK request_set(struct _cef_request_t* self, const wchar_t* url,
const wchar_t* method, struct _cef_post_data_t* postData,
cef_string_map_t headerMap)
{
DCHECK(request);
if(!request)
return;
DCHECK(self);
if(!self)
return;
std::wstring urlStr, methodStr;
CefRefPtr<CefPostData> postDataPtr;
CefRequest::HeaderMap map;
@ -134,13 +155,15 @@ void CEF_CALLBACK request_set(struct _cef_request_t* request,
if(headerMap)
transfer_string_map_contents(headerMap, map);
CefRequestCppToC::Get(request)->Set(urlStr, methodStr, postDataPtr, map);
CefRequestCppToC::Get(self)->Set(urlStr, methodStr, postDataPtr, map);
}
CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
: CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>(cls)
{
// CONSTRUCTOR - Do not edit by hand.
CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
: CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>(cls)
{
struct_.struct_.get_url = request_get_url;
struct_.struct_.set_url = request_set_url;
struct_.struct_.get_method = request_get_method;
@ -149,188 +172,10 @@ CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
struct_.struct_.set_post_data = request_set_post_data;
struct_.struct_.get_header_map = request_get_header_map;
struct_.struct_.set_header_map = request_set_header_map;
struct_.struct_.set = request_set;
}
struct_.struct_.set = request_set;
}
#ifdef _DEBUG
long CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>::DebugObjCt = 0;
#endif
size_t CEF_CALLBACK post_data_get_element_count(
struct _cef_post_data_t* postData)
{
DCHECK(postData);
if(!postData)
return 0;
return CefPostDataCppToC::Get(postData)->GetElementCount();
}
struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_element(
struct _cef_post_data_t* postData, int index)
{
DCHECK(postData);
if(!postData)
return NULL;
CefPostData::ElementVector elements;
CefPostDataCppToC::Get(postData)->GetElements(elements);
if(index < 0 || index >= (int)elements.size())
return NULL;
return CefPostDataElementCppToC::Wrap(elements[index]);
}
int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* postData,
struct _cef_post_data_element_t* element)
{
DCHECK(postData);
DCHECK(element);
if(!postData || !element)
return 0;
CefRefPtr<CefPostDataElement> postDataElementPtr =
CefPostDataElementCppToC::Unwrap(element);
return CefPostDataCppToC::Get(postData)->RemoveElement(postDataElementPtr);
}
int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* postData,
struct _cef_post_data_element_t* element)
{
DCHECK(postData);
DCHECK(element);
if(!postData || !element)
return 0;
CefRefPtr<CefPostDataElement> postDataElementPtr =
CefPostDataElementCppToC::Unwrap(element);
return CefPostDataCppToC::Get(postData)->AddElement(postDataElementPtr);
}
void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* postData)
{
DCHECK(postData);
if(!postData)
return;
CefPostDataCppToC::Get(postData)->RemoveElements();
}
CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
: CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>(cls)
{
struct_.struct_.get_element_count = post_data_get_element_count;
struct_.struct_.get_element = post_data_get_element;
struct_.struct_.remove_element = post_data_remove_element;
struct_.struct_.add_element = post_data_add_element;
struct_.struct_.remove_elements = post_data_remove_elements;
}
#ifdef _DEBUG
long CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>::DebugObjCt
= 0;
#endif
void CEF_CALLBACK post_data_element_set_to_empty(
struct _cef_post_data_element_t* postDataElement)
{
DCHECK(postDataElement);
if(!postDataElement)
return;
CefPostDataElementCppToC::Get(postDataElement)->SetToEmpty();
}
void CEF_CALLBACK post_data_element_set_to_file(
struct _cef_post_data_element_t* postDataElement,
const wchar_t* fileName)
{
DCHECK(postDataElement);
if(!postDataElement)
return;
std::wstring fileNameStr;
if(fileName)
fileNameStr = fileName;
CefPostDataElementCppToC::Get(postDataElement)->SetToFile(fileNameStr);
}
void CEF_CALLBACK post_data_element_set_to_bytes(
struct _cef_post_data_element_t* postDataElement, size_t size,
const void* bytes)
{
DCHECK(postDataElement);
if(!postDataElement)
return;
CefPostDataElementCppToC::Get(postDataElement)->SetToBytes(size, bytes);
}
cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
struct _cef_post_data_element_t* postDataElement)
{
DCHECK(postDataElement);
if(!postDataElement)
return PDE_TYPE_EMPTY;
return CefPostDataElementCppToC::Get(postDataElement)->GetType();
}
cef_string_t CEF_CALLBACK post_data_element_get_file(
struct _cef_post_data_element_t* postDataElement)
{
DCHECK(postDataElement);
if(!postDataElement)
return NULL;
std::wstring fileNameStr =
CefPostDataElementCppToC::Get(postDataElement)->GetFile();
if(!fileNameStr.empty())
return cef_string_alloc(fileNameStr.c_str());
return NULL;
}
size_t CEF_CALLBACK post_data_element_get_bytes_count(
struct _cef_post_data_element_t* postDataElement)
{
DCHECK(postDataElement);
if(!postDataElement)
return 0;
return CefPostDataElementCppToC::Get(postDataElement)->GetBytesCount();
}
size_t CEF_CALLBACK post_data_element_get_bytes(
struct _cef_post_data_element_t* postDataElement, size_t size,
void *bytes)
{
DCHECK(postDataElement);
if(!postDataElement)
return 0;
return CefPostDataElementCppToC::Get(postDataElement)->GetBytes(size, bytes);
}
CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
: CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>(cls)
{
struct_.struct_.set_to_empty = post_data_element_set_to_empty;
struct_.struct_.set_to_file = post_data_element_set_to_file;
struct_.struct_.set_to_bytes = post_data_element_set_to_bytes;
struct_.struct_.get_type = post_data_element_get_type;
struct_.struct_.get_file = post_data_element_get_file;
struct_.struct_.get_bytes_count = post_data_element_get_bytes_count;
struct_.struct_.get_bytes = post_data_element_get_bytes;
}
#ifdef _DEBUG
long CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>::DebugObjCt = 0;
#endif

View File

@ -1,54 +1,34 @@
// 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 _REQUEST_CPPTOC_H
#define _REQUEST_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _REQUEST_CPPTOC_H
#define _REQUEST_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefRequestCppToC
: public CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>
{
public:
CefRequestCppToC(CefRequest* cls);
virtual ~CefRequestCppToC() {}
};
// Wrap a C++ request class with a C request structure.
// This class may be instantiated and accessed DLL-side only.
class CefRequestCppToC
: public CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>
{
public:
CefRequestCppToC(CefRequest* cls);
virtual ~CefRequestCppToC() {}
};
// Wrap a C++ post data class with a C post data structure.
// This class may be instantiated and accessed DLL-side only.
class CefPostDataCppToC
: public CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>
{
public:
CefPostDataCppToC(CefPostData* cls);
virtual ~CefPostDataCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _REQUEST_CPPTOC_H
class CefPostDataElementCppToC;
// Wrap a C++ post data element class with a C post data element structure.
// This class may be instantiated and accessed DLL-side only.
class CefPostDataElementCppToC
: public CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>
{
public:
CefPostDataElementCppToC(CefPostDataElement* cls);
virtual ~CefPostDataElementCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _REQUEST_CPPTOC_H

View File

@ -1,116 +0,0 @@
// 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.
#include "../precompiled_libcef.h"
#include "cpptoc/stream_cpptoc.h"
size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* stream,
void *ptr, size_t size, size_t n)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamReaderCppToC::Get(stream)->Read(ptr, size, n);
}
int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* stream,
long offset, int whence)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamReaderCppToC::Get(stream)->Seek(offset, whence);
}
long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* stream)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamReaderCppToC::Get(stream)->Tell();
}
int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* stream)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamReaderCppToC::Get(stream)->Eof();
}
CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
: CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t>(cls)
{
struct_.struct_.read = stream_reader_read;
struct_.struct_.seek = stream_reader_seek;
struct_.struct_.tell = stream_reader_tell;
struct_.struct_.eof = stream_reader_eof;
}
#ifdef _DEBUG
long CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t>::DebugObjCt = 0;
#endif
size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* stream,
const void *ptr, size_t size, size_t n)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamWriterCppToC::Get(stream)->Write(ptr, size, n);
}
int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* stream,
long offset, int whence)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamWriterCppToC::Get(stream)->Seek(offset, whence);
}
long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* stream)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamWriterCppToC::Get(stream)->Tell();
}
int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* stream)
{
DCHECK(stream);
if(!stream)
return 0;
return CefStreamWriterCppToC::Get(stream)->Flush();
}
CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
: CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t>(cls)
{
struct_.struct_.write = stream_writer_write;
struct_.struct_.seek = stream_writer_seek;
struct_.struct_.tell = stream_writer_tell;
struct_.struct_.flush = stream_writer_flush;
}
#ifdef _DEBUG
long CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,98 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/stream_reader_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
const wchar_t* fileName)
{
std::wstring filenamestr;
if(fileName)
filenamestr = fileName;
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForFile(filenamestr);
if(impl.get())
return CefStreamReaderCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void *data,
size_t size)
{
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForData(data, size);
if(impl.get())
return CefStreamReaderCppToC::Wrap(impl);
return NULL;
}
// MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* self,
void *ptr, size_t size, size_t n)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamReaderCppToC::Get(self)->Read(ptr, size, n);
}
int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* self,
long offset, int whence)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamReaderCppToC::Get(self)->Seek(offset, whence);
}
long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamReaderCppToC::Get(self)->Tell();
}
int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamReaderCppToC::Get(self)->Eof();
}
// CONSTRUCTOR - Do not edit by hand.
CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
: CefCppToC<CefStreamReaderCppToC, CefStreamReader, cef_stream_reader_t>(
cls)
{
struct_.struct_.read = stream_reader_read;
struct_.struct_.seek = stream_reader_seek;
struct_.struct_.tell = stream_reader_tell;
struct_.struct_.eof = stream_reader_eof;
}
#ifdef _DEBUG
long CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t>::DebugObjCt = 0;
#endif

View File

@ -1,42 +1,35 @@
// 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 _STREAM_CPPTOC_H
#define _STREAM_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _STREAMREADER_CPPTOC_H
#define _STREAMREADER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefStreamReaderCppToC
: public CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t>
{
public:
CefStreamReaderCppToC(CefStreamReader* cls);
virtual ~CefStreamReaderCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _STREAMREADER_CPPTOC_H
// Wrap a C++ stream reader class with a C stream reader structure.
// This class may be instantiated and accessed DLL-side only.
class CefStreamReaderCppToC
: public CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t>
{
public:
CefStreamReaderCppToC(CefStreamReader* cls);
virtual ~CefStreamReaderCppToC() {}
};
// Wrap a C++ stream writer class with a C stream writer structure.
// This class may be instantiated and accessed DLL-side only.
class CefStreamWriterCppToC
: public CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t>
{
public:
CefStreamWriterCppToC(CefStreamWriter* cls);
virtual ~CefStreamWriterCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _STREAM_CPPTOC_H

View File

@ -0,0 +1,74 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/stream_writer_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* self,
const void *ptr, size_t size, size_t n)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamWriterCppToC::Get(self)->Write(ptr, size, n);
}
int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* self,
long offset, int whence)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamWriterCppToC::Get(self)->Seek(offset, whence);
}
long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamWriterCppToC::Get(self)->Tell();
}
int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefStreamWriterCppToC::Get(self)->Flush();
}
// CONSTRUCTOR - Do not edit by hand.
CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
: CefCppToC<CefStreamWriterCppToC, CefStreamWriter, cef_stream_writer_t>(
cls)
{
struct_.struct_.write = stream_writer_write;
struct_.struct_.seek = stream_writer_seek;
struct_.struct_.tell = stream_writer_tell;
struct_.struct_.flush = stream_writer_flush;
}
#ifdef _DEBUG
long CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,35 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _STREAMWRITER_CPPTOC_H
#define _STREAMWRITER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefStreamWriterCppToC
: public CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t>
{
public:
CefStreamWriterCppToC(CefStreamWriter* cls);
virtual ~CefStreamWriterCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _STREAMWRITER_CPPTOC_H

View File

@ -1,54 +1,70 @@
// 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.
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/v8handler_cpptoc.h"
#include "ctocpp/v8value_ctocpp.h"
int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* v8handler,
const wchar_t* name, struct _cef_v8value_t* object, size_t numargs,
struct _cef_v8value_t** args, struct _cef_v8value_t** retval,
cef_string_t* exception)
{
DCHECK(v8handler);
if(!v8handler)
return RV_CONTINUE;
CefRefPtr<CefV8Value> objectPtr;
if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object);
std::wstring nameStr;
if(name)
nameStr = name;
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self,
const wchar_t* name, struct _cef_v8value_t* object, size_t argumentCount,
const struct _cef_v8value_t** arguments, struct _cef_v8value_t** retval,
cef_string_t* exception)
{
DCHECK(self);
if(!self)
return RV_CONTINUE;
CefRefPtr<CefV8Value> objectPtr;
if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object);
std::wstring nameStr;
if(name)
nameStr = name;
CefV8ValueList list;
for(size_t i = 0; i < numargs; ++i)
list.push_back(CefV8ValueCToCpp::Wrap(args[i]));
CefRefPtr<CefV8Value> retValPtr;
std::wstring exceptionStr;
bool rv = CefV8HandlerCppToC::Get(v8handler)->Execute(nameStr, objectPtr,
list, retValPtr, exceptionStr);
if(rv) {
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
if(retValPtr.get() && retval)
*retval = CefV8ValueCToCpp::Unwrap(retValPtr);
}
return rv;
for(size_t i = 0; i < argumentCount; ++i) {
list.push_back(CefV8ValueCToCpp::Wrap(
const_cast<cef_v8value_t*>(arguments[i])));
}
CefRefPtr<CefV8Value> retValPtr;
std::wstring exceptionStr;
bool rv = CefV8HandlerCppToC::Get(self)->Execute(nameStr, objectPtr,
list, retValPtr, exceptionStr);
if(rv) {
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
if(retValPtr.get() && retval)
*retval = CefV8ValueCToCpp::Unwrap(retValPtr);
}
return rv;
}
CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls)
: CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>(cls)
{
struct_.struct_.execute = v8handler_execute;
}
// CONSTRUCTOR - Do not edit by hand.
CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls)
: CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>(cls)
{
struct_.struct_.execute = v8handler_execute;
}
#ifdef _DEBUG
long CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>::DebugObjCt
= 0;
long CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>::DebugObjCt =
0;
#endif

View File

@ -1,29 +1,34 @@
// 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 _V8HANDLER_CPPTOC_H
#define _V8HANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _V8HANDLER_CPPTOC_H
#define _V8HANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefV8HandlerCppToC
: public CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>
{
public:
CefV8HandlerCppToC(CefV8Handler* cls);
virtual ~CefV8HandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _V8HANDLER_CPPTOC_H
// Wrap a C++ v8handler class with a C v8handler structure.
// This class may be instantiated and accessed wrapper-side only.
class CefV8HandlerCppToC
: public CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>
{
public:
CefV8HandlerCppToC(CefV8Handler* cls);
virtual ~CefV8HandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _V8HANDLER_CPPTOC_H

View File

@ -1,330 +1,434 @@
// 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.
// 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/v8value_cpptoc.h"
#include "ctocpp/v8handler_ctocpp.h"
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsUndefined();
}
int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsNull();
}
int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsBool();
}
int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsInt();
}
int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsDouble();
}
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsString();
}
int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsObject();
}
int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsArray();
}
int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->IsFunction();
}
#include "cpptoc/v8value_cpptoc.h"
#include "ctocpp/base_ctocpp.h"
#include "ctocpp/v8handler_ctocpp.h"
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->GetBoolValue();
}
int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->GetIntValue();
}
// GLOBAL FUNCTIONS - Body may be edited by hand.
double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->GetDoubleValue();
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateUndefined();
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::wstring valueStr = CefV8ValueCppToC::Get(v8value)->GetStringValue();
if(!valueStr.empty())
return cef_string_alloc(valueStr.c_str());
return NULL;
}
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* v8value,
const wchar_t* key)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(v8value)->HasValue(keyStr);
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_null()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateNull();
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* v8value,
int index)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->HasValue(index);
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateBool(value?true:false);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* v8value,
const wchar_t* key)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(v8value)->DeleteValue(keyStr);
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateInt(value);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* v8value,
int index)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->DeleteValue(index);
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateDouble(value);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value)
{
std::wstring valueStr;
if(value)
valueStr = value;
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data)
{
CefRefPtr<CefBase> basePtr;
if(user_data)
basePtr = CefBaseCToCpp::Wrap(user_data);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateObject(basePtr);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_array()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray();
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name,
cef_v8handler_t* handler)
{
std::wstring nameStr;
if(name)
nameStr = name;
CefRefPtr<CefV8Handler> handlerPtr;
if(handler)
handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsUndefined();
}
int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsNull();
}
int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsBool();
}
int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsInt();
}
int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsDouble();
}
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsString();
}
int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsObject();
}
int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsArray();
}
int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->IsFunction();
}
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->GetBoolValue();
}
int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->GetIntValue();
}
double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->GetDoubleValue();
}
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
std::wstring valueStr = CefV8ValueCppToC::Get(self)->GetStringValue();
if(!valueStr.empty())
return cef_string_alloc(valueStr.c_str());
return NULL;
}
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(self)->HasValue(keyStr);
}
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self,
int index)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->HasValue(index);
}
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(self)->DeleteValue(keyStr);
}
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self,
int index)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->DeleteValue(index);
}
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey(
struct _cef_v8value_t* v8value, const wchar_t* key)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(v8value)->GetValue(keyStr);
return CefV8ValueCppToC::Wrap(valuePtr);
}
struct _cef_v8value_t* self, const wchar_t* key)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(self)->GetValue(keyStr);
return CefV8ValueCppToC::Wrap(valuePtr);
}
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex(
struct _cef_v8value_t* v8value, int index)
{
DCHECK(v8value);
if(!v8value)
return 0;
CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(v8value)->GetValue(index);
return CefV8ValueCppToC::Wrap(valuePtr);
}
struct _cef_v8value_t* self, int index)
{
DCHECK(self);
if(!self)
return 0;
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* v8value,
const wchar_t* key, struct _cef_v8value_t* new_value)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(new_value);
return CefV8ValueCppToC::Get(v8value)->SetValue(keyStr, valuePtr);
}
CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(self)->GetValue(index);
return CefV8ValueCppToC::Wrap(valuePtr);
}
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* v8value,
int index, struct _cef_v8value_t* new_value)
{
DCHECK(v8value);
if(!v8value)
return 0;
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(new_value);
return CefV8ValueCppToC::Get(v8value)->SetValue(index, valuePtr);
}
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key, struct _cef_v8value_t* value)
{
DCHECK(self);
if(!self)
return 0;
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* v8value,
cef_string_list_t list)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::vector<std::wstring> keysList;
CefV8ValueCppToC::Get(v8value)->GetKeys(keysList);
size_t size = keysList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(list, keysList[i].c_str());
return size;
}
std::wstring keyStr;
if(key)
keyStr = key;
struct _cef_base_t* CEF_CALLBACK v8value_get_user_data(
struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(v8value)->GetUserData();
if(base.get())
return CefBaseCToCpp::Unwrap(base);
return NULL;
}
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
return CefV8ValueCppToC::Get(self)->SetValue(keyStr, valuePtr);
}
int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
return CefV8ValueCppToC::Get(v8value)->GetArrayLength();
}
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
int index, struct _cef_v8value_t* value)
{
DCHECK(self);
if(!self)
return 0;
cef_string_t CEF_CALLBACK v8value_get_function_name(
struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
std::wstring functionNameStr =
CefV8ValueCppToC::Get(v8value)->GetFunctionName();
if(!functionNameStr.empty())
return cef_string_alloc(functionNameStr.c_str());
return NULL;
}
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
return CefV8ValueCppToC::Get(self)->SetValue(index, valuePtr);
}
struct _cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
struct _cef_v8value_t* v8value)
{
DCHECK(v8value);
if(!v8value)
return 0;
CefRefPtr<CefV8Handler> handlerPtr =
CefV8ValueCppToC::Get(v8value)->GetFunctionHandler();
if(handlerPtr.get())
return CefV8HandlerCToCpp::Unwrap(handlerPtr);
return NULL;
}
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self,
cef_string_list_t keys)
{
DCHECK(self);
if(!self)
return 0;
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* v8value,
struct _cef_v8value_t* object, size_t numargs,
struct _cef_v8value_t** args, struct _cef_v8value_t** retval,
cef_string_t* exception)
{
DCHECK(v8value);
DCHECK(object);
if(!v8value || !object)
return 0;
CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object);
CefV8ValueList argsList;
for(size_t i = 0; i < numargs; i++)
argsList.push_back(CefV8ValueCppToC::Unwrap(args[i]));
CefRefPtr<CefV8Value> retvalPtr;
std::wstring exceptionStr;
bool rv = CefV8ValueCppToC::Get(v8value)->ExecuteFunction(objectPtr,
argsList, retvalPtr, exceptionStr);
if(retvalPtr.get() && retval)
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
return rv;
}
std::vector<std::wstring> keysList;
CefV8ValueCppToC::Get(self)->GetKeys(keysList);
size_t size = keysList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(keys, keysList[i].c_str());
return size;
}
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls)
{
cef_base_t* CEF_CALLBACK v8value_get_user_data(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(self)->GetUserData();
if(base.get())
return CefBaseCToCpp::Unwrap(base);
return NULL;
}
int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
return CefV8ValueCppToC::Get(self)->GetArrayLength();
}
cef_string_t CEF_CALLBACK v8value_get_function_name(struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
std::wstring functionNameStr =
CefV8ValueCppToC::Get(self)->GetFunctionName();
if(!functionNameStr.empty())
return cef_string_alloc(functionNameStr.c_str());
return NULL;
}
cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
CefRefPtr<CefV8Handler> handlerPtr =
CefV8ValueCppToC::Get(self)->GetFunctionHandler();
if(handlerPtr.get())
return CefV8HandlerCToCpp::Unwrap(handlerPtr);
return NULL;
}
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
struct _cef_v8value_t* object, size_t argumentCount,
const struct _cef_v8value_t** arguments, struct _cef_v8value_t** retval,
cef_string_t* exception)
{
DCHECK(self);
DCHECK(object);
if(!self || !object)
return 0;
CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object);
CefV8ValueList argsList;
for(size_t i = 0; i < argumentCount; i++) {
argsList.push_back(CefV8ValueCppToC::Unwrap(
const_cast<cef_v8value_t*>(arguments[i])));
}
CefRefPtr<CefV8Value> retvalPtr;
std::wstring exceptionStr;
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
argsList, retvalPtr, exceptionStr);
if(retvalPtr.get() && retval)
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
return rv;
}
// CONSTRUCTOR - Do not edit by hand.
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls)
{
struct_.struct_.is_undefined = v8value_is_undefined;
struct_.struct_.is_null = v8value_is_null;
struct_.struct_.is_bool = v8value_is_bool;
@ -351,9 +455,10 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
struct_.struct_.get_array_length = v8value_get_array_length;
struct_.struct_.get_function_name = v8value_get_function_name;
struct_.struct_.get_function_handler = v8value_get_function_handler;
struct_.struct_.execute_function = v8value_execute_function;
}
struct_.struct_.execute_function = v8value_execute_function;
}
#ifdef _DEBUG
long CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>::DebugObjCt = 0;
#endif

View File

@ -1,29 +1,34 @@
// 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 _V8VALUE_CPPTOC_H
#define _V8VALUE_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
// 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _V8VALUE_CPPTOC_H
#define _V8VALUE_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefV8ValueCppToC
: public CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>
{
public:
CefV8ValueCppToC(CefV8Value* cls);
virtual ~CefV8ValueCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _V8VALUE_CPPTOC_H
// Wrap a C++ v8value class with a C v8value structure.
// This class may be instantiated and accessed wrapper-side only.
class CefV8ValueCppToC
: public CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>
{
public:
CefV8ValueCppToC(CefV8Value* cls);
virtual ~CefV8ValueCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _V8VALUE_CPPTOC_H