- 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

@ -1,31 +1,38 @@
// Copyright (c) 2008-2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (c) 2008-2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef _CEF_H
@ -47,8 +54,8 @@ class CefStreamReader;
class CefStreamWriter;
class CefV8Handler;
class CefV8Value;
// This function should only be called once when the application is started.
// Create the thread to host the UI message loop. A return value of true
// indicates that it succeeded and false indicates that it failed. Set
@ -57,61 +64,64 @@ class CefV8Value;
// the CefDoMessageLoopWork() function must be called from your message loop.
// Set |cache_path| to the location where cache data will be stored on disk.
// If |cache_path| is empty an in-memory cache will be used for cache data.
/*--cef()--*/
bool CefInitialize(bool multi_threaded_message_loop,
const std::wstring& cache_path);
// This function should only be called once before the application exits.
// Shut down the thread hosting the UI message loop and destroy any created
// windows.
/*--cef()--*/
void CefShutdown();
// Perform message loop processing. Has no affect if the browser UI loop is
// running in a separate thread.
/*--cef()--*/
void CefDoMessageLoopWork();
// Register a new V8 extension with the specified JavaScript extension code and
// handler. Functions implemented by the handler are prototyped using the
// keyword 'native'. The calling of a native function is restricted to the scope
// handler. Functions implemented by the handler are prototyped using the
// keyword 'native'. The calling of a native function is restricted to the scope
// in which the prototype of the native function is defined.
//
// Example JavaScript extension code:
//
// // create the 'example' global object if it doesn't already exist.
// if (!example)
// example = {};
// if (!example)
// example = {};
// // create the 'example.test' global object if it doesn't already exist.
// if (!example.test)
// example.test = {};
// (function() {
// // Define the function 'example.test.myfunction'.
// example.test.myfunction = function() {
// // Call CefV8Handler::Execute() with the function name 'MyFunction'
// // and no arguments.
// native function MyFunction();
// return MyFunction();
// };
// // Define the getter function for parameter 'example.test.myparam'.
// example.test.__defineGetter__('myparam', function() {
// // Call CefV8Handler::Execute() with the function name 'GetMyParam'
// // and no arguments.
// native function GetMyParam();
// return GetMyParam();
// });
// // Define the setter function for parameter 'example.test.myparam'.
// example.test.__defineSetter__('myparam', function(b) {
// // Call CefV8Handler::Execute() with the function name 'SetMyParam'
// // and a single argument.
// native function SetMyParam();
// if(b) SetMyParam(b);
// });
//
// // Extension definitions can also contain normal JavaScript variables
// // and functions.
// var myint = 0;
// example.test.increment = function() {
// myint += 1;
// return myint;
// };
// if (!example.test)
// example.test = {};
// (function() {
// // Define the function 'example.test.myfunction'.
// example.test.myfunction = function() {
// // Call CefV8Handler::Execute() with the function name 'MyFunction'
// // and no arguments.
// native function MyFunction();
// return MyFunction();
// };
// // Define the getter function for parameter 'example.test.myparam'.
// example.test.__defineGetter__('myparam', function() {
// // Call CefV8Handler::Execute() with the function name 'GetMyParam'
// // and no arguments.
// native function GetMyParam();
// return GetMyParam();
// });
// // Define the setter function for parameter 'example.test.myparam'.
// example.test.__defineSetter__('myparam', function(b) {
// // Call CefV8Handler::Execute() with the function name 'SetMyParam'
// // and a single argument.
// native function SetMyParam();
// if(b) SetMyParam(b);
// });
//
// // Extension definitions can also contain normal JavaScript variables
// // and functions.
// var myint = 0;
// example.test.increment = function() {
// myint += 1;
// return myint;
// };
// })();
//
// Example usage in the page:
@ -125,6 +135,7 @@ void CefDoMessageLoopWork();
// // Call another function.
// example.test.increment();
//
/*--cef()--*/
bool CefRegisterExtension(const std::wstring& extension_name,
const std::wstring& javascript_code,
CefRefPtr<CefV8Handler> handler);
@ -221,6 +232,7 @@ protected:
// Class used to represent a browser window. All methods exposed by this class
// should be thread safe.
/*--cef(source=library)--*/
class CefBrowser : public CefBase
{
public:
@ -229,6 +241,7 @@ public:
// window will be created on the UI thread. The |popup| parameter should
// be true if the new window is a popup window. This method call will not
// block.
/*--cef()--*/
static bool CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url);
@ -237,118 +250,154 @@ public:
// by |windowInfo|. The |popup| parameter should be true if the new window is
// a popup window. This method call will block and can only be used if
// the |multi_threaded_message_loop| parameter to CefInitialize() is false.
/*--cef()--*/
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url);
// Returns true if the browser can navigate backwards.
/*--cef()--*/
virtual bool CanGoBack() =0;
// Navigate backwards.
/*--cef()--*/
virtual void GoBack() =0;
// Returns true if the browser can navigate forwards.
/*--cef()--*/
virtual bool CanGoForward() =0;
// Navigate backwards.
/*--cef()--*/
virtual void GoForward() =0;
// Reload the current page.
/*--cef()--*/
virtual void Reload() =0;
// Stop loading the page.
/*--cef()--*/
virtual void StopLoad() =0;
// Set focus for the browser window. If |enable| is true focus will be set
// to the window. Otherwise, focus will be removed.
/*--cef()--*/
virtual void SetFocus(bool enable) =0;
// Retrieve the window handle for this browser.
/*--cef()--*/
virtual CefWindowHandle GetWindowHandle() =0;
// Returns true if the window is a popup window.
/*--cef()--*/
virtual bool IsPopup() =0;
// Returns the handler for this browser.
/*--cef()--*/
virtual CefRefPtr<CefHandler> GetHandler() =0;
// Returns the main (top-level) frame for the browser window.
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetMainFrame() =0;
// Returns the focused frame for the browser window.
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetFocusedFrame() =0;
// Returns the frame with the specified name, or NULL if not found.
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name) =0;
// Returns the names of all existing frames.
/*--cef()--*/
virtual void GetFrameNames(std::vector<std::wstring>& names) =0;
};
// Class used to represent a frame in the browser window. All methods exposed
// by this class should be thread safe.
/*--cef(source=library)--*/
class CefFrame : public CefBase
{
public:
// Execute undo in this frame.
/*--cef()--*/
virtual void Undo() =0;
// Execute redo in this frame.
/*--cef()--*/
virtual void Redo() =0;
// Execute cut in this frame.
/*--cef()--*/
virtual void Cut() =0;
// Execute copy in this frame.
/*--cef()--*/
virtual void Copy() =0;
// Execute paste in this frame.
/*--cef()--*/
virtual void Paste() =0;
// Execute delete in this frame.
/*--cef(capi_name=del)--*/
virtual void Delete() =0;
// Execute select all in this frame.
/*--cef()--*/
virtual void SelectAll() =0;
// Execute printing in the this frame. The user will be prompted with the
// print dialog appropriate to the operating system.
/*--cef()--*/
virtual void Print() =0;
// Save this frame's HTML source to a temporary file and open it in the
// default text viewing application.
/*--cef()--*/
virtual void ViewSource() =0;
// Returns this frame's HTML source as a string.
/*--cef()--*/
virtual std::wstring GetSource() =0;
// Returns this frame's display text as a string.
/*--cef()--*/
virtual std::wstring GetText() =0;
// Load the request represented by the |request| object.
/*--cef()--*/
virtual void LoadRequest(CefRefPtr<CefRequest> request) =0;
// Load the specified |url|.
/*--cef()--*/
virtual void LoadURL(const std::wstring& url) =0;
// Load the contents of |string| with the optional dummy target |url|.
/*--cef()--*/
virtual void LoadString(const std::wstring& string,
const std::wstring& url) =0;
// Load the contents of |stream| with the optional dummy target |url|.
/*--cef()--*/
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url) =0;
// Execute a string of JavaScript code in this frame. The |script_url|
// parameter is the URL where the script in question can be found, if any.
// Execute a string of JavaScript code in this frame. The |script_url|
// parameter is the URL where the script in question can be found, if any.
// The renderer may request this URL to show the developer the source of the
// error. The |start_line| parameter is the base line number to use for error
// reporting.
/*--cef()--*/
virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl,
int startLine) =0;
// Returns true if this is the main frame.
/*--cef()--*/
virtual bool IsMain() =0;
// Returns true if this is the focused frame.
/*--cef()--*/
virtual bool IsFocused() =0;
// Returns this frame's name.
/*--cef()--*/
virtual std::wstring GetName() =0;
// Return the URL currently loaded in this frame.
/*--cef()--*/
virtual std::wstring GetURL() =0;
};
@ -356,6 +405,7 @@ public:
// Interface that should be implemented to handle events generated by the
// browser window. All methods exposed by this class should be thread safe.
// Each method in the interface returns a RetVal value.
/*--cef(source=client)--*/
class CefHandler : public CefBase
{
public:
@ -374,6 +424,7 @@ public:
// create the window. By default, a newly created window will recieve the
// same handler as the parent window. To change the handler for the new
// window modify the object that |handler| points to.
/*--cef()--*/
virtual RetVal HandleBeforeCreated(CefRefPtr<CefBrowser> parentBrowser,
CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler>& handler,
@ -381,16 +432,19 @@ public:
// Event called after a new window is created. The return value is currently
// ignored.
/*--cef()--*/
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser) =0;
// Event called when a frame's address has changed. The return value is
// currently ignored.
/*--cef()--*/
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& url) =0;
// Event called when the page title changes. The return value is currently
// ignored.
/*--cef()--*/
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title) =0;
@ -400,6 +454,7 @@ public:
// Event called before browser navigation. The client has an opportunity to
// modify the |request| object if desired. Return RV_HANDLED to cancel
// navigation.
/*--cef()--*/
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
@ -408,6 +463,7 @@ public:
// Event called when the browser begins loading a page. The |frame| pointer
// will be empty if the event represents the overall load status and not the
// load status for a particular frame. The return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) =0;
@ -416,6 +472,7 @@ public:
// load status for a particular frame. This event will be generated
// irrespective of whether the request completes successfully. The return
// value is currently ignored.
/*--cef()--*/
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) =0;
@ -427,6 +484,7 @@ public:
// error code number and |failedUrl| is the URL that failed to load. To
// provide custom error text assign the text to |errorText| and return
// RV_HANDLED. Otherwise, return RV_CONTINUE for the default error text.
/*--cef()--*/
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
@ -437,8 +495,9 @@ public:
// normally return RV_CONTINUE. To redirect the resource to a new url
// populate the |redirectUrl| value and return RV_CONTINUE. To specify
// data for the resource return a CefStream object in |resourceStream|, set
// 'mimeType| to the resource stream's mime type, and return RV_CONTINUE.
// |mimeType| to the resource stream's mime type, and return RV_CONTINUE.
// To cancel loading of the resource return RV_HANDLED.
/*--cef()--*/
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request,
std::wstring& redirectUrl,
@ -451,6 +510,7 @@ public:
// Event called before a context menu is displayed. To cancel display of the
// default context menu return RV_HANDLED.
/*--cef()--*/
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
const MenuInfo& menuInfo) =0;
@ -460,11 +520,13 @@ public:
// Event called to optionally override the default text for a context menu
// item. |label| contains the default text and may be modified to substitute
// alternate text. The return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
MenuId menuId, std::wstring& label) =0;
// Event called when an option is selected from the default context menu.
// Return RV_HANDLED to cancel default handling of the action.
/*--cef()--*/
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser,
MenuId menuId) =0;
@ -478,6 +540,7 @@ public:
// just assign a string to the appropriate variable. To draw the header
// and footer yourself return RV_HANDLED. Otherwise, populate the approprate
// variables and return RV_CONTINUE.
/*--cef()--*/
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo,
@ -493,40 +556,46 @@ public:
// Run a JS alert message. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert.
/*--cef()--*/
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message) =0;
const std::wstring& message) =0;
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
// set |retval| to true if the user accepted the confirmation.
/*--cef()--*/
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval) =0;
const std::wstring& message, bool& retval) =0;
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
// set |retval| to true if the user accepted the prompt and request and
// |result| to the resulting value.
/*--cef()--*/
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message,
const std::wstring& defaultValue,
bool& retval,
const std::wstring& message,
const std::wstring& defaultValue,
bool& retval,
std::wstring& result) =0;
// Called just before a window is closed. The return value is currently
// ignored.
/*--cef()--*/
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser) =0;
// Called when the browser component is about to loose focus. For instance,
// if focus was on the last HTML element and the user pressed the TAB key.
// The return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser,
bool reverse) =0;
// Event called for adding values to a frame's JavaScript 'window' object. The
// Event called for adding values to a frame's JavaScript 'window' object. The
// return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Value> object) =0;
@ -535,38 +604,50 @@ public:
// true if the focus is requested for a child widget of the browser window.
// Return RV_CONTINUE to allow the focus to be set or RV_HANDLED to cancel
// setting the focus.
/*--cef()--*/
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser,
bool isWidget) =0;
};
// Class used to represent a web request.
/*--cef(source=library)--*/
class CefRequest : public CefBase
{
public:
typedef std::map<std::wstring, std::wstring> HeaderMap;
typedef std::map<std::wstring,std::wstring> HeaderMap;
// Create a new CefRequest object.
/*--cef()--*/
static CefRefPtr<CefRequest> CreateRequest();
// Fully qualified URL to load.
/*--cef()--*/
virtual std::wstring GetURL() =0;
/*--cef()--*/
virtual void SetURL(const std::wstring& url) =0;
// Optional request method type, defaulting to POST if post data is provided
// and GET otherwise.
/*--cef()--*/
virtual std::wstring GetMethod() =0;
/*--cef()--*/
virtual void SetMethod(const std::wstring& method) =0;
// Optional post data.
/*--cef()--*/
virtual CefRefPtr<CefPostData> GetPostData() =0;
/*--cef()--*/
virtual void SetPostData(CefRefPtr<CefPostData> postData) =0;
// Optional header values.
/*--cef()--*/
virtual void GetHeaderMap(HeaderMap& headerMap) =0;
/*--cef()--*/
virtual void SetHeaderMap(const HeaderMap& headerMap) =0;
// Set all values at one time.
/*--cef()--*/
virtual void Set(const std::wstring& url,
const std::wstring& method,
CefRefPtr<CefPostData> postData,
@ -575,33 +656,41 @@ public:
// Class used to represent post data for a web request.
/*--cef(source=library)--*/
class CefPostData : public CefBase
{
public:
typedef std::vector<CefRefPtr<CefPostDataElement> > ElementVector;
typedef std::vector<CefRefPtr<CefPostDataElement>> ElementVector;
// Create a new CefPostData object.
/*--cef()--*/
static CefRefPtr<CefPostData> CreatePostData();
// Returns the number of existing post data elements.
/*--cef()--*/
virtual size_t GetElementCount() =0;
// Retrieve the post data elements.
/*--cef()--*/
virtual void GetElements(ElementVector& elements) =0;
// Remove the specified post data element. Returns true if the removal
// succeeds.
/*--cef()--*/
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element) =0;
// Add the specified post data element. Returns true if the add succeeds.
/*--cef()--*/
virtual bool AddElement(CefRefPtr<CefPostDataElement> element) =0;
// Remove all existing post data elements.
/*--cef()--*/
virtual void RemoveElements() =0;
};
// Class used to represent a single element in the request post data.
/*--cef(source=library)--*/
class CefPostDataElement : public CefBase
{
public:
@ -609,70 +698,91 @@ public:
typedef cef_postdataelement_type_t Type;
// Create a new CefPostDataElement object.
/*--cef()--*/
static CefRefPtr<CefPostDataElement> CreatePostDataElement();
// Remove all contents from the post data element.
/*--cef()--*/
virtual void SetToEmpty() =0;
// The post data element will represent a file.
/*--cef()--*/
virtual void SetToFile(const std::wstring& fileName) =0;
// The post data element will represent bytes. The bytes passed
// in will be copied.
/*--cef()--*/
virtual void SetToBytes(size_t size, const void* bytes) =0;
// Return the type of this post data element.
/*--cef()--*/
virtual Type GetType() =0;
// Return the file name.
/*--cef()--*/
virtual std::wstring GetFile() =0;
// Return the number of bytes.
/*--cef()--*/
virtual size_t GetBytesCount() =0;
// Read up to |size| bytes into |bytes| and return the number of bytes
// actually read.
/*--cef()--*/
virtual size_t GetBytes(size_t size, void *bytes) =0;
};
// Class used to read data from a stream.
/*--cef(source=library)--*/
class CefStreamReader : public CefBase
{
public:
// Create a new CefStreamReader object.
/*--cef()--*/
static CefRefPtr<CefStreamReader> CreateForFile(const std::wstring& fileName);
/*--cef()--*/
static CefRefPtr<CefStreamReader> CreateForData(void *data, size_t size);
// Read raw binary data.
/*--cef()--*/
virtual size_t Read(void *ptr, size_t size, size_t n) =0;
// Seek to the specified offset position. |whence| may be any one of
// SEEK_CUR, SEEK_END or SEEK_SET.
/*--cef()--*/
virtual int Seek(long offset, int whence) =0;
// Return the current offset position.
/*--cef()--*/
virtual long Tell() =0;
// Return non-zero if at end of file.
/*--cef()--*/
virtual int Eof() =0;
};
// Class used to write data to a stream.
/*--cef(source=library)--*/
class CefStreamWriter : public CefBase
{
public:
// Write raw binary data.
/*--cef()--*/
virtual size_t Write(const void *ptr, size_t size, size_t n) =0;
// Seek to the specified offset position. |whence| may be any one of
// SEEK_CUR, SEEK_END or SEEK_SET.
/*--cef()--*/
virtual int Seek(long offset, int whence) =0;
// Return the current offset position.
/*--cef()--*/
virtual long Tell() =0;
// Flush the stream.
/*--cef()--*/
virtual int Flush() =0;
};
@ -680,54 +790,79 @@ public:
typedef std::vector<CefRefPtr<CefV8Value>> CefV8ValueList;
// Interface that should be implemented to handle V8 function calls.
/*--cef(source=client)--*/
class CefV8Handler : public CefBase
{
public:
// Execute with the specified argument list and return value. Return true if
// the method was handled.
/*--cef()--*/
virtual bool Execute(const std::wstring& name,
CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception) =0;
};
// Class representing a V8 value.
/*--cef(source=library)--*/
class CefV8Value : public CefBase
{
public:
// Create a new value of the specified type. These functions should only be
// called from within the JavaScript context -- either in a
// CefV8Handler::Execute() callback or a CefHandler::HandleScriptBinding()
// Create a new CefV8Value object of the specified type. These methods
// should only be called from within the JavaScript context -- either in a
// CefV8Handler::Execute() callback or a CefHandler::HandleJSBinding()
// callback.
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateUndefined();
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateNull();
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateBool(bool value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateInt(int value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateDouble(double value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateString(const std::wstring& value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateObject(CefRefPtr<CefBase> user_data);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateArray();
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateFunction(const std::wstring& name,
CefRefPtr<CefV8Handler> handler);
// Check the value type.
/*--cef()--*/
virtual bool IsUndefined() =0;
/*--cef()--*/
virtual bool IsNull() =0;
/*--cef()--*/
virtual bool IsBool() =0;
/*--cef()--*/
virtual bool IsInt() =0;
/*--cef()--*/
virtual bool IsDouble() =0;
/*--cef()--*/
virtual bool IsString() =0;
/*--cef()--*/
virtual bool IsObject() =0;
/*--cef()--*/
virtual bool IsArray() =0;
/*--cef()--*/
virtual bool IsFunction() =0;
// Return a primitive value type. The underlying data will be converted to
// the requested type if necessary.
/*--cef()--*/
virtual bool GetBoolValue() =0;
/*--cef()--*/
virtual int GetIntValue() =0;
/*--cef()--*/
virtual double GetDoubleValue() =0;
/*--cef()--*/
virtual std::wstring GetStringValue() =0;
@ -737,46 +872,60 @@ public:
// Keys beginning with "Cef::" and "v8::" are reserved by the system.
// Returns true if the object has a value with the specified identifier.
/*--cef(capi_name=has_value_bykey)--*/
virtual bool HasValue(const std::wstring& key) =0;
/*--cef(capi_name=has_value_byindex)--*/
virtual bool HasValue(int index) =0;
// Delete the value with the specified identifier.
/*--cef(capi_name=delete_value_bykey)--*/
virtual bool DeleteValue(const std::wstring& key) =0;
/*--cef(capi_name=delete_value_byindex)--*/
virtual bool DeleteValue(int index) =0;
// Returns the value with the specified identifier.
/*--cef(capi_name=get_value_bykey)--*/
virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key) =0;
/*--cef(capi_name=get_value_byindex)--*/
virtual CefRefPtr<CefV8Value> GetValue(int index) =0;
// Associate value with the specified identifier.
/*--cef(capi_name=set_value_bykey)--*/
virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value) =0;
/*--cef(capi_name=set_value_byindex)--*/
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) =0;
// Read the keys for the object's values into the specified vector. Integer-
// based keys will also be returned as strings.
/*--cef()--*/
virtual bool GetKeys(std::vector<std::wstring>& keys) =0;
// Returns the user data, if any, specified when the object was created.
/*--cef()--*/
virtual CefRefPtr<CefBase> GetUserData() =0;
// ARRAY METHODS - These methods are only available on arrays.
// Returns the number of elements in the array.
/*--cef()--*/
virtual int GetArrayLength() =0;
// FUNCTION METHODS - These methods are only available on functions.
// Returns the function name.
/*--cef()--*/
virtual std::wstring GetFunctionName() =0;
// Returns the function handler or NULL if not a CEF-created function.
/*--cef()--*/
virtual CefRefPtr<CefV8Handler> GetFunctionHandler() =0;
// Execute the function.
/*--cef()--*/
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception) =0;
};

File diff suppressed because it is too large Load Diff

View File

@ -649,9 +649,9 @@ CefRefPtr<CefV8Handler> CefV8ValueImpl::GetFunctionHandler()
}
bool CefV8ValueImpl::ExecuteFunction(CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
{
bool rv = false;
Lock();

View File

@ -49,7 +49,7 @@ public:
virtual std::wstring GetFunctionName();
virtual CefRefPtr<CefV8Handler> GetFunctionHandler();
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception);

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

View File

@ -0,0 +1,95 @@
// 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_CTOCPP_H
#define _BASE_CTOCPP_H
#include "cef.h"
#include "cef_capi.h"
#include "../cef_logging.h"
// CefCToCpp implementation for CefBase.
class CefBaseCToCpp : public CefThreadSafeBase<CefBase>
{
public:
// Use this method to create a wrapper class instance for a structure
// received from the other side.
static CefRefPtr<CefBase> Wrap(cef_base_t* s)
{
// Wrap their structure with the CefCToCpp object.
CefBaseCToCpp* wrapper = new CefBaseCToCpp(s);
// Put the wrapper object in a smart pointer.
CefRefPtr<CefBase> wrapperPtr(wrapper);
// Release the reference that was added to the CefCppToC wrapper object on
// the other side before their structure was passed to us.
wrapper->UnderlyingRelease();
// Return the smart pointer.
return wrapperPtr;
}
// Use this method to retrieve the underlying structure from a wrapper class
// instance for return back to the other side.
static cef_base_t* Unwrap(CefRefPtr<CefBase> c)
{
// Cast the object to our wrapper class type.
CefBaseCToCpp* wrapper = static_cast<CefBaseCToCpp*>(c.get());
// Add a reference to the CefCppToC wrapper object on the other side that
// will be released once the structure is received.
wrapper->UnderlyingAddRef();
// Return their original structure.
return wrapper->GetStruct();
}
CefBaseCToCpp(cef_base_t* str)
: struct_(str)
{
DCHECK(str);
}
virtual ~CefBaseCToCpp() {}
// If returning the structure across the DLL boundary you should call
// UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of
// the DLL boundary, call Release() on the CefCppToC object.
cef_base_t* GetStruct() { return struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapped structure.
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()
{
if(!struct_->add_ref)
return 0;
return struct_->add_ref(struct_);
}
int UnderlyingRelease()
{
if(!struct_->release)
return 0;
return struct_->release(struct_);
}
int UnderlyingGetRefCt()
{
if(!struct_->get_refct)
return 0;
return struct_->get_refct(struct_);
}
protected:
cef_base_t* struct_;
};
#endif // _BASE_CTOCPP_H

View File

@ -1,13 +1,43 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/browser_ctocpp.h"
#include "cpptoc/handler_cpptoc.h"
#include "ctocpp/browser_ctocpp.h"
#include "ctocpp/frame_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler, const std::wstring& url)
{
return cef_browser_create(&windowInfo, popup, CefHandlerCppToC::Wrap(handler),
url.c_str());
}
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup, CefRefPtr<CefHandler> handler, const std::wstring& url)
{
cef_browser_t* impl = cef_browser_create_sync(&windowInfo, popup,
CefHandlerCppToC::Wrap(handler), url.c_str());
if(impl)
return CefBrowserCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
bool CefBrowserCToCpp::CanGoBack()
{
if(CEF_MEMBER_MISSING(struct_, can_go_back))
@ -147,6 +177,8 @@ void CefBrowserCToCpp::GetFrameNames(std::vector<std::wstring>& names)
cef_string_list_free(list);
}
#ifdef _DEBUG
long CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>::DebugObjCt = 0;
#endif

View File

@ -1,29 +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 _BROWSER_CTOCPP_H
#define _BROWSER_CTOCPP_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 _BROWSER_CTOCPP_H
#define _BROWSER_CTOCPP_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 "ctocpp.h"
// Wrap a C browser structure with a C++ browser class.
// This class may be instantiated and accessed wrapper-side only.
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefBrowserCToCpp
: public CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>
{
public:
CefBrowserCToCpp(cef_browser_t* str)
: CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>(str) {}
virtual ~CefBrowserCToCpp() {}
public:
CefBrowserCToCpp(cef_browser_t* str)
: CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>(str) {}
virtual ~CefBrowserCToCpp() {}
// CefBrowser methods
virtual bool CanGoBack();
virtual void GoBack();
@ -38,9 +44,9 @@ public:
virtual CefRefPtr<CefFrame> GetMainFrame();
virtual CefRefPtr<CefFrame> GetFocusedFrame();
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name);
virtual void GetFrameNames(std::vector<std::wstring>& names);
};
#endif // USING_CEF_SHARED
#endif // _BROWSER_CTOCPP_H
virtual void GetFrameNames(std::vector<std::wstring>& names);
};
#endif // USING_CEF_SHARED
#endif // _BROWSER_CTOCPP_H

View File

@ -1,193 +1,111 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef _CTOCPP_H
#define _CTOCPP_H
#include "cef.h"
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef _CTOCPP_H
#define _CTOCPP_H
#include "cef.h"
#include "cef_capi.h"
#include "../cef_logging.h"
// Wrap a C structure with a C++ class. This is used when the implementation
// exists on the other side of the DLL boundary but will have methods called on
// this side of the DLL boundary.
#include "../cef_logging.h"
// Wrap a C structure with a C++ class. This is used when the implementation
// exists on the other side of the DLL boundary but will have methods called on
// this side of the DLL boundary.
template <class ClassName, class BaseName, class StructName>
class CefCToCpp : public CefThreadSafeBase<BaseName>
{
public:
// Use this method to create a wrapper class instance for a structure
// received from the other side.
static CefRefPtr<BaseName> Wrap(StructName* s)
{
// Wrap their structure with the CefCToCpp object.
public:
// Use this method to create a wrapper class instance for a structure
// received from the other side.
static CefRefPtr<BaseName> Wrap(StructName* s)
{
// Wrap their structure with the CefCToCpp object.
ClassName* wrapper = new ClassName(s);
// Put the wrapper object in a smart pointer.
CefRefPtr<BaseName> wrapperPtr(wrapper);
// Release the reference that was added to the CefCppToC wrapper object on
// the other side before their structure was passed to us.
wrapper->UnderlyingRelease();
// Return the smart pointer.
return wrapperPtr;
}
// Use this method to retrieve the underlying structure from a wrapper class
// instance for return back to the other side.
static StructName* Unwrap(CefRefPtr<BaseName> c)
{
// Cast the object to our wrapper class type.
ClassName* wrapper = static_cast<ClassName*>(c.get());
// Add a reference to the CefCppToC wrapper object on the other side that
// will be released once the structure is received.
wrapper->UnderlyingAddRef();
// Return their original structure.
return wrapper->GetStruct();
}
CefCToCpp(StructName* str)
: struct_(str)
{
DCHECK(str);
#ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCToCpp()
{
#ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
}
// If returning the structure across the DLL boundary you should call
// UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of
// the DLL boundary, call Release() on the CefCppToC object.
StructName* GetStruct() { return struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapped structure.
CefRefPtr<BaseName> wrapperPtr(wrapper);
// Release the reference that was added to the CefCppToC wrapper object on
// the other side before their structure was passed to us.
wrapper->UnderlyingRelease();
// Return the smart pointer.
return wrapperPtr;
}
// Use this method to retrieve the underlying structure from a wrapper class
// instance for return back to the other side.
static StructName* Unwrap(CefRefPtr<BaseName> c)
{
// Cast the object to our wrapper class type.
ClassName* wrapper = static_cast<ClassName*>(c.get());
// Add a reference to the CefCppToC wrapper object on the other side that
// will be released once the structure is received.
wrapper->UnderlyingAddRef();
// Return their original structure.
return wrapper->GetStruct();
}
CefCToCpp(StructName* str)
: struct_(str)
{
DCHECK(str);
#ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCToCpp()
{
#ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
}
// If returning the structure across the DLL boundary you should call
// UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of
// the DLL boundary, call Release() on the CefCppToC object.
StructName* GetStruct() { return struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapped structure.
virtual int AddRef()
{
UnderlyingAddRef();
return CefThreadSafeBase<BaseName>::AddRef();
}
virtual int Release()
{
virtual int Release()
{
UnderlyingRelease();
return CefThreadSafeBase<BaseName>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef()
{
return CefThreadSafeBase<BaseName>::Release();
}
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef()
{
if(!struct_->base.add_ref)
return 0;
return struct_->base.add_ref(&struct_->base);
}
int UnderlyingRelease()
{
if(!struct_->base.release)
return 0;
return struct_->base.release(&struct_->base);
}
int UnderlyingGetRefCt()
{
if(!struct_->base.get_refct)
return 0;
return struct_->base.get_refct(&struct_->base);
}
#ifdef _DEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
#endif
protected:
StructName* struct_;
return struct_->base.add_ref(&struct_->base);
}
int UnderlyingRelease()
{
if(!struct_->base.release)
return 0;
return struct_->base.release(&struct_->base);
}
int UnderlyingGetRefCt()
{
if(!struct_->base.get_refct)
return 0;
return struct_->base.get_refct(&struct_->base);
}
#ifdef _DEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
#endif
protected:
StructName* struct_;
};
// CefCToCpp implementation for CefBase.
class CefBaseCToCpp : public CefThreadSafeBase<CefBase>
{
public:
// Use this method to create a wrapper class instance for a structure
// received from the other side.
static CefRefPtr<CefBase> Wrap(cef_base_t* s)
{
// Wrap their structure with the CefCToCpp object.
CefBaseCToCpp* wrapper = new CefBaseCToCpp(s);
// Put the wrapper object in a smart pointer.
CefRefPtr<CefBase> wrapperPtr(wrapper);
// Release the reference that was added to the CefCppToC wrapper object on
// the other side before their structure was passed to us.
wrapper->UnderlyingRelease();
// Return the smart pointer.
return wrapperPtr;
}
// Use this method to retrieve the underlying structure from a wrapper class
// instance for return back to the other side.
static cef_base_t* Unwrap(CefRefPtr<CefBase> c)
{
// Cast the object to our wrapper class type.
CefBaseCToCpp* wrapper = static_cast<CefBaseCToCpp*>(c.get());
// Add a reference to the CefCppToC wrapper object on the other side that
// will be released once the structure is received.
wrapper->UnderlyingAddRef();
// Return their original structure.
return wrapper->GetStruct();
}
CefBaseCToCpp(cef_base_t* str)
: struct_(str)
{
DCHECK(str);
}
virtual ~CefBaseCToCpp() {}
// If returning the structure across the DLL boundary you should call
// UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of
// the DLL boundary, call Release() on the CefCppToC object.
cef_base_t* GetStruct() { return struct_; }
// CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapped structure.
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()
{
if(!struct_->add_ref)
return 0;
return struct_->add_ref(struct_);
}
int UnderlyingRelease()
{
if(!struct_->release)
return 0;
return struct_->release(struct_);
}
int UnderlyingGetRefCt()
{
if(!struct_->get_refct)
return 0;
return struct_->get_refct(struct_);
}
protected:
cef_base_t* struct_;
};
#endif // _CTOCPP_H
#endif // _CTOCPP_H

View File

@ -1,13 +1,23 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/frame_ctocpp.h"
#include "ctocpp/request_ctocpp.h"
#include "ctocpp/stream_ctocpp.h"
#include "ctocpp/stream_reader_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefFrameCToCpp::Undo()
{
if(CEF_MEMBER_MISSING(struct_, undo))
@ -125,7 +135,7 @@ void CefFrameCToCpp::LoadURL(const std::wstring& url)
}
void CefFrameCToCpp::LoadString(const std::wstring& string,
const std::wstring& url)
const std::wstring& url)
{
if(CEF_MEMBER_MISSING(struct_, load_string))
return;
@ -134,7 +144,7 @@ void CefFrameCToCpp::LoadString(const std::wstring& string,
}
void CefFrameCToCpp::LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url)
const std::wstring& url)
{
if(CEF_MEMBER_MISSING(struct_, load_stream))
return;
@ -143,15 +153,14 @@ void CefFrameCToCpp::LoadStream(CefRefPtr<CefStreamReader> stream,
url.c_str());
}
void CefFrameCToCpp::ExecuteJavaScript(const std::wstring& js_code,
const std::wstring& script_url,
int start_line)
void CefFrameCToCpp::ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl, int startLine)
{
if(CEF_MEMBER_MISSING(struct_, execute_javascript))
if(CEF_MEMBER_MISSING(struct_, execute_java_script))
return;
struct_->execute_javascript(struct_, js_code.c_str(), script_url.c_str(),
start_line);
struct_->execute_java_script(struct_, jsCode.c_str(), scriptUrl.c_str(),
startLine);
}
bool CefFrameCToCpp::IsMain()
@ -198,6 +207,8 @@ std::wstring CefFrameCToCpp::GetURL()
return str;
}
#ifdef _DEBUG
long CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>::DebugObjCt = 0;
#endif

View File

@ -1,28 +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 _FRAME_CTOCPP_H
#define _FRAME_CTOCPP_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 _FRAME_CTOCPP_H
#define _FRAME_CTOCPP_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 "ctocpp.h"
// Wrap a C frame structure with a C++ frame class.
// This class may be instantiated and accessed wrapper-side only.
class CefFrameCToCpp : public CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefFrameCToCpp
: public CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>
{
public:
CefFrameCToCpp(cef_frame_t* str)
: CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>(str) {}
virtual ~CefFrameCToCpp() {}
public:
CefFrameCToCpp(cef_frame_t* str)
: CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>(str) {}
virtual ~CefFrameCToCpp() {}
// CefFrame methods
virtual void Undo();
virtual void Redo();
@ -37,19 +44,17 @@ public:
virtual std::wstring GetText();
virtual void LoadRequest(CefRefPtr<CefRequest> request);
virtual void LoadURL(const std::wstring& url);
virtual void LoadString(const std::wstring& string,
const std::wstring& url);
virtual void LoadString(const std::wstring& string, const std::wstring& url);
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url);
virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl,
int startLine);
const std::wstring& url);
virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl, int startLine);
virtual bool IsMain();
virtual bool IsFocused();
virtual std::wstring GetName();
virtual std::wstring GetURL();
};
#endif // USING_CEF_SHARED
#endif // _FRAME_CTOCPP_H
virtual std::wstring GetURL();
};
#endif // USING_CEF_SHARED
#endif // _FRAME_CTOCPP_H

View File

@ -1,17 +1,27 @@
// 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 static and
// virtual method 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 "cpptoc/request_cpptoc.h"
#include "cpptoc/stream_cpptoc.h"
#include "cpptoc/stream_reader_cpptoc.h"
#include "cpptoc/v8value_cpptoc.h"
#include "ctocpp/handler_ctocpp.h"
#include "transfer_util.h"
#include "../transfer_util.h"
// VIRTUAL METHODS - Body may be edited by hand.
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated(
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler>& handler, std::wstring& url)
@ -122,7 +132,8 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd(
CefHandler::RetVal CefHandlerCToCpp::HandleLoadError(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
ErrorCode errorCode, const std::wstring& failedUrl, std::wstring& errorText)
ErrorCode errorCode, const std::wstring& failedUrl,
std::wstring& errorText)
{
if(CEF_MEMBER_MISSING(struct_, handle_load_error))
return RV_CONTINUE;
@ -208,10 +219,11 @@ CefHandler::RetVal CefHandlerCToCpp::HandleMenuAction(
CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo, const std::wstring& url, const std::wstring& title,
int currentPage, int maxPages, std::wstring& topLeft,
std::wstring& topCenter, std::wstring& topRight, std::wstring& bottomLeft,
std::wstring& bottomCenter, std::wstring& bottomRight)
CefPrintInfo& printInfo, const std::wstring& url,
const std::wstring& title, int currentPage, int maxPages,
std::wstring& topLeft, std::wstring& topCenter, std::wstring& topRight,
std::wstring& bottomLeft, std::wstring& bottomCenter,
std::wstring& bottomRight)
{
if(CEF_MEMBER_MISSING(struct_, handle_print_header_footer))
return RV_CONTINUE;
@ -258,7 +270,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSAlert(
return struct_->handle_jsalert(struct_, CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame), message.c_str());
}
CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval)
@ -273,11 +285,11 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm(
retval = (ret ? true : false);
return rv;
}
CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& message, const std::wstring& defaultValue, bool& retval,
std::wstring& result)
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& message, const std::wstring& defaultValue,
bool& retval, std::wstring& result)
{
if(CEF_MEMBER_MISSING(struct_, handle_jsprompt))
return RV_CONTINUE;
@ -297,16 +309,16 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt(
return rv;
}
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeWindowClose(
CefRefPtr<CefBrowser> browser)
{
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeWindowClose(
CefRefPtr<CefBrowser> browser)
{
if(CEF_MEMBER_MISSING(struct_, handle_before_window_close))
return RV_CONTINUE;
return struct_->handle_before_window_close(struct_,
CefBrowserCppToC::Wrap(browser));
}
return struct_->handle_before_window_close(struct_,
CefBrowserCppToC::Wrap(browser));
}
CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus(
CefRefPtr<CefBrowser> browser, bool reverse)
{
@ -317,7 +329,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus(
reverse);
}
CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding(
CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Value> object)
{
@ -331,13 +343,15 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding(
CefHandler::RetVal CefHandlerCToCpp::HandleSetFocus(
CefRefPtr<CefBrowser> browser, bool isWidget)
{
if(CEF_MEMBER_MISSING(struct_, handle_set_focus))
return RV_CONTINUE;
if(CEF_MEMBER_MISSING(struct_, handle_set_focus))
return RV_CONTINUE;
return struct_->handle_set_focus(struct_, CefBrowserCppToC::Wrap(browser),
isWidget);
return struct_->handle_set_focus(struct_, CefBrowserCppToC::Wrap(browser),
isWidget);
}
#ifdef _DEBUG
long CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>::DebugObjCt = 0;
#endif

View File

@ -1,99 +1,83 @@
// 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_CTOCPP_H
#define _HANDLER_CTOCPP_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 _HANDLER_CTOCPP_H
#define _HANDLER_CTOCPP_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 "ctocpp.h"
// Wrap a C handler structure with a C++ handler class.
// This class may be instantiated and accessed DLL-side only.
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefHandlerCToCpp
: public CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>
{
public:
CefHandlerCToCpp(cef_handler_t* str)
: CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>(str) {}
virtual ~CefHandlerCToCpp() {}
public:
CefHandlerCToCpp(cef_handler_t* str)
: CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>(str) {}
virtual ~CefHandlerCToCpp() {}
// CefHandler methods
virtual RetVal HandleBeforeCreated(CefRefPtr<CefBrowser> parentBrowser,
CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler>& handler,
std::wstring& url);
CefWindowInfo& windowInfo, bool popup, CefRefPtr<CefHandler>& handler,
std::wstring& url);
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser);
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& url);
CefRefPtr<CefFrame> frame, const std::wstring& url);
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title);
const std::wstring& title);
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
NavType navType, bool isRedirect);
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
NavType navType, bool isRedirect);
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame);
CefRefPtr<CefFrame> frame);
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame);
CefRefPtr<CefFrame> frame);
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const std::wstring& failedUrl,
std::wstring& errorText);
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const std::wstring& failedUrl, std::wstring& errorText);
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request,
std::wstring& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType,
int loadFlags);
CefRefPtr<CefRequest> request, std::wstring& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream, std::wstring& mimeType,
int loadFlags);
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
const MenuInfo& menuInfo);
const MenuInfo& menuInfo);
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
MenuId menuId, std::wstring& label);
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser,
MenuId menuId);
MenuId menuId, std::wstring& label);
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser, MenuId menuId);
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo,
const std::wstring& url,
const std::wstring& title,
int currentPage, int maxPages,
std::wstring& topLeft,
std::wstring& topCenter,
std::wstring& topRight,
std::wstring& bottomLeft,
std::wstring& bottomCenter,
std::wstring& bottomRight);
CefRefPtr<CefFrame> frame, CefPrintInfo& printInfo,
const std::wstring& url, const std::wstring& title, int currentPage,
int maxPages, std::wstring& topLeft, std::wstring& topCenter,
std::wstring& topRight, std::wstring& bottomLeft,
std::wstring& bottomCenter, std::wstring& bottomRight);
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message);
CefRefPtr<CefFrame> frame, const std::wstring& message);
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval);
CefRefPtr<CefFrame> frame, const std::wstring& message, bool& retval);
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message,
const std::wstring& default_value,
bool& retval,
std::wstring& result);
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser);
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser,
bool reverse);
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Value> object);
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser,
bool isWidget);
};
#endif // BUILDING_CEF_SHARED
#endif // _HANDLER_CTOCPP_H
CefRefPtr<CefFrame> frame, const std::wstring& message,
const std::wstring& defaultValue, bool& retval, std::wstring& result);
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser);
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser, bool reverse);
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Value> object);
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser, bool isWidget);
};
#endif // BUILDING_CEF_SHARED
#endif // _HANDLER_CTOCPP_H

View File

@ -0,0 +1,86 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/post_data_ctocpp.h"
#include "ctocpp/post_data_element_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefPostData> CefPostData::CreatePostData()
{
cef_post_data_t* impl = cef_post_data_create();
if(impl)
return CefPostDataCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
size_t CefPostDataCToCpp::GetElementCount()
{
if(CEF_MEMBER_MISSING(struct_, get_element_count))
return 0;
return struct_->get_element_count(struct_);
}
void CefPostDataCToCpp::GetElements(ElementVector& elements)
{
if(CEF_MEMBER_MISSING(struct_, get_elements))
return;
int count = (int)GetElementCount();
cef_post_data_element_t* structPtr;
for(int i = 0; i < count; ++i) {
structPtr = struct_->get_elements(struct_, i);
if(structPtr)
elements.push_back(CefPostDataElementCToCpp::Wrap(structPtr));
}
}
bool CefPostDataCToCpp::RemoveElement(CefRefPtr<CefPostDataElement> element)
{
DCHECK(element.get());
if(CEF_MEMBER_MISSING(struct_, remove_element) || !element.get())
return false;
return struct_->remove_element(struct_,
CefPostDataElementCToCpp::Unwrap(element));
}
bool CefPostDataCToCpp::AddElement(CefRefPtr<CefPostDataElement> element)
{
DCHECK(element.get());
if(CEF_MEMBER_MISSING(struct_, add_element) || !element.get())
return false;
return struct_->add_element(struct_,
CefPostDataElementCToCpp::Unwrap(element));
}
void CefPostDataCToCpp::RemoveElements()
{
if(CEF_MEMBER_MISSING(struct_, remove_elements))
return;
return struct_->remove_elements(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,43 @@
// 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_CTOCPP_H
#define _POSTDATA_CTOCPP_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 "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefPostDataCToCpp
: public CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>
{
public:
CefPostDataCToCpp(cef_post_data_t* str)
: CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>(str) {}
virtual ~CefPostDataCToCpp() {}
// CefPostData methods
virtual size_t GetElementCount();
virtual void GetElements(ElementVector& elements);
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element);
virtual bool AddElement(CefRefPtr<CefPostDataElement> element);
virtual void RemoveElements();
};
#endif // USING_CEF_SHARED
#endif // _POSTDATA_CTOCPP_H

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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/post_data_element_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefPostDataElement> CefPostDataElement::CreatePostDataElement()
{
cef_post_data_element_t* impl = cef_post_data_element_create();
if(impl)
return CefPostDataElementCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
void CefPostDataElementCToCpp::SetToEmpty()
{
if(CEF_MEMBER_MISSING(struct_, set_to_empty))
return;
return struct_->set_to_empty(struct_);
}
void CefPostDataElementCToCpp::SetToFile(const std::wstring& fileName)
{
if(CEF_MEMBER_MISSING(struct_, set_to_file))
return;
return struct_->set_to_file(struct_, fileName.c_str());
}
void CefPostDataElementCToCpp::SetToBytes(size_t size, const void* bytes)
{
if(CEF_MEMBER_MISSING(struct_, set_to_bytes))
return;
return struct_->set_to_bytes(struct_, size, bytes);
}
CefPostDataElement::Type CefPostDataElementCToCpp::GetType()
{
if(CEF_MEMBER_MISSING(struct_, get_type))
return PDE_TYPE_EMPTY;
return struct_->get_type(struct_);
}
std::wstring CefPostDataElementCToCpp::GetFile()
{
std::wstring str;
if(CEF_MEMBER_MISSING(struct_, get_file))
return str;
cef_string_t cef_str = struct_->get_file(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
return str;
}
size_t CefPostDataElementCToCpp::GetBytesCount()
{
if(CEF_MEMBER_MISSING(struct_, get_bytes_count))
return 0;
return struct_->get_bytes_count(struct_);
}
size_t CefPostDataElementCToCpp::GetBytes(size_t size, void *bytes)
{
if(CEF_MEMBER_MISSING(struct_, get_bytes))
return 0;
return struct_->get_bytes(struct_, size, bytes);
}
#ifdef _DEBUG
long CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
cef_post_data_element_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,47 @@
// 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_CTOCPP_H
#define _POSTDATAELEMENT_CTOCPP_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 "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefPostDataElementCToCpp
: public CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
cef_post_data_element_t>
{
public:
CefPostDataElementCToCpp(cef_post_data_element_t* str)
: CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
cef_post_data_element_t>(str) {}
virtual ~CefPostDataElementCToCpp() {}
// CefPostDataElement methods
virtual void SetToEmpty();
virtual void SetToFile(const std::wstring& fileName);
virtual void SetToBytes(size_t size, const void* bytes);
virtual Type GetType();
virtual std::wstring GetFile();
virtual size_t GetBytesCount();
virtual size_t GetBytes(size_t size, void *bytes);
};
#endif // USING_CEF_SHARED
#endif // _POSTDATAELEMENT_CTOCPP_H

View File

@ -1,10 +1,33 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/post_data_ctocpp.h"
#include "ctocpp/request_ctocpp.h"
#include "transfer_util.h"
#include "../transfer_util.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefRequest> CefRequest::CreateRequest()
{
cef_request_t* impl = cef_request_create();
if(impl)
return CefRequestCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
std::wstring CefRequestCToCpp::GetURL()
{
@ -106,10 +129,8 @@ void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap)
cef_string_map_free(map);
}
void CefRequestCToCpp::Set(const std::wstring& url,
const std::wstring& method,
CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap)
void CefRequestCToCpp::Set(const std::wstring& url, const std::wstring& method,
CefRefPtr<CefPostData> postData, const HeaderMap& headerMap)
{
if(CEF_MEMBER_MISSING(struct_, set))
return;
@ -132,132 +153,8 @@ void CefRequestCToCpp::Set(const std::wstring& url,
cef_string_map_free(map);
}
#ifdef _DEBUG
long CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>::DebugObjCt = 0;
#endif
size_t CefPostDataCToCpp::GetElementCount()
{
if(CEF_MEMBER_MISSING(struct_, get_element_count))
return 0;
return struct_->get_element_count(struct_);
}
void CefPostDataCToCpp::GetElements(ElementVector& elements)
{
if(CEF_MEMBER_MISSING(struct_, get_element))
return;
int count = (int)GetElementCount();
cef_post_data_element_t* structPtr;
for(int i = 0; i < count; ++i) {
structPtr = struct_->get_element(struct_, i);
if(structPtr)
elements.push_back(CefPostDataElementCToCpp::Wrap(structPtr));
}
}
bool CefPostDataCToCpp::RemoveElement(CefRefPtr<CefPostDataElement> element)
{
DCHECK(element.get());
if(CEF_MEMBER_MISSING(struct_, remove_element) || !element.get())
return false;
return struct_->remove_element(struct_,
CefPostDataElementCToCpp::Unwrap(element));
}
bool CefPostDataCToCpp::AddElement(CefRefPtr<CefPostDataElement> element)
{
DCHECK(element.get());
if(CEF_MEMBER_MISSING(struct_, add_element) || !element.get())
return false;
return struct_->add_element(struct_,
CefPostDataElementCToCpp::Unwrap(element));
}
void CefPostDataCToCpp::RemoveElements()
{
if(CEF_MEMBER_MISSING(struct_, remove_elements))
return;
return struct_->remove_elements(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>::DebugObjCt = 0;
#endif
void CefPostDataElementCToCpp::SetToEmpty()
{
if(CEF_MEMBER_MISSING(struct_, set_to_empty))
return;
return struct_->set_to_empty(struct_);
}
void CefPostDataElementCToCpp::SetToFile(const std::wstring& fileName)
{
if(CEF_MEMBER_MISSING(struct_, set_to_file))
return;
return struct_->set_to_file(struct_, fileName.c_str());
}
void CefPostDataElementCToCpp::SetToBytes(size_t size, const void* bytes)
{
if(CEF_MEMBER_MISSING(struct_, set_to_bytes))
return;
return struct_->set_to_bytes(struct_, size, bytes);
}
CefPostDataElement::Type CefPostDataElementCToCpp::GetType()
{
if(CEF_MEMBER_MISSING(struct_, get_type))
return PDE_TYPE_EMPTY;
return struct_->get_type(struct_);
}
std::wstring CefPostDataElementCToCpp::GetFile()
{
std::wstring str;
if(CEF_MEMBER_MISSING(struct_, get_file))
return str;
cef_string_t cef_str = struct_->get_file(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
return str;
}
size_t CefPostDataElementCToCpp::GetBytesCount()
{
if(CEF_MEMBER_MISSING(struct_, get_bytes_count))
return 0;
return struct_->get_bytes_count(struct_);
}
size_t CefPostDataElementCToCpp::GetBytes(size_t size, void *bytes)
{
if(CEF_MEMBER_MISSING(struct_, get_bytes))
return 0;
return struct_->get_bytes(struct_, size, bytes);
}
#ifdef _DEBUG
long CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
cef_post_data_element_t>::DebugObjCt = 0;
#endif

View File

@ -1,30 +1,36 @@
// 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_CTOCPP_H
#define _REQUEST_CTOCPP_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 _REQUEST_CTOCPP_H
#define _REQUEST_CTOCPP_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 "ctocpp.h"
// Wrap a C request structure with a C++ request class.
// This class may be instantiated and accessed wrapper-side only.
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefRequestCToCpp
: public CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>
{
public:
CefRequestCToCpp(cef_request_t* str)
: CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>(str) {}
virtual ~CefRequestCToCpp() {}
// CefRequest methods
public:
CefRequestCToCpp(cef_request_t* str)
: CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>(str) {}
virtual ~CefRequestCToCpp() {}
// CefRequest methods
virtual std::wstring GetURL();
virtual void SetURL(const std::wstring& url);
virtual std::wstring GetMethod();
@ -33,54 +39,10 @@ public:
virtual void SetPostData(CefRefPtr<CefPostData> postData);
virtual void GetHeaderMap(HeaderMap& headerMap);
virtual void SetHeaderMap(const HeaderMap& headerMap);
virtual void Set(const std::wstring& url,
const std::wstring& method,
CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap);
};
// Wrap a C post data structure with a C++ post data class.
// This class may be instantiated and accessed wrapper-side only.
class CefPostDataCToCpp
: public CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>
{
public:
CefPostDataCToCpp(cef_post_data_t* str)
: CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>(str) {}
virtual ~CefPostDataCToCpp() {}
virtual void Set(const std::wstring& url, const std::wstring& method,
CefRefPtr<CefPostData> postData, const HeaderMap& headerMap);
};
#endif // USING_CEF_SHARED
#endif // _REQUEST_CTOCPP_H
// CefPostData methods
virtual size_t GetElementCount();
virtual void GetElements(ElementVector& elements);
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element);
virtual bool AddElement(CefRefPtr<CefPostDataElement> element);
virtual void RemoveElements();
};
// Wrap a C post data element structure with a C++ post data element class.
// This class may be instantiated and accessed wrapper-side only.
class CefPostDataElementCToCpp
: public CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
cef_post_data_element_t>
{
public:
CefPostDataElementCToCpp(cef_post_data_element_t* str)
: CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
cef_post_data_element_t>(str) {}
virtual ~CefPostDataElementCToCpp() {}
// CefPostDataElement methods
virtual void SetToEmpty();
virtual void SetToFile(const std::wstring& fileName);
virtual void SetToBytes(size_t size, const void* bytes);
virtual Type GetType();
virtual std::wstring GetFile();
virtual size_t GetBytesCount();
virtual size_t GetBytes(size_t size, void *bytes);
};
#endif // USING_CEF_SHARED
#endif // _REQUEST_CTOCPP_H

View File

@ -1,58 +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.
#ifndef _STREAM_CTOCPP_H
#define _STREAM_CTOCPP_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 "ctocpp.h"
// Wrap a C stream reader structure with a C++ stream reader class.
// This class may be instantiated and accessed wrapper-side only.
class CefStreamReaderCToCpp
: public CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
cef_stream_reader_t>
{
public:
CefStreamReaderCToCpp(cef_stream_reader_t* str)
: CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
cef_stream_reader_t>(str) {}
virtual ~CefStreamReaderCToCpp() {}
// CefStreamReader methods
virtual size_t Read(void *ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence);
virtual long Tell();
virtual int Eof();
};
// Wrap a C stream writer structure with a C++ stream writer class.
// This class may be instantiated and accessed wrapper-side only.
class CefStreamWriterCToCpp
: public CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
cef_stream_writer_t>
{
public:
CefStreamWriterCToCpp(cef_stream_writer_t* str)
: CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
cef_stream_writer_t>(str) {}
virtual ~CefStreamWriterCToCpp() {}
// CefStreamWriter methods
virtual size_t Write(const void *ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence);
virtual long Tell();
virtual int Flush();
};
#endif // USING_CEF_SHARED
#endif // _STREAM_CTOCPP_H

View File

@ -0,0 +1,78 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/stream_reader_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(
const std::wstring& fileName)
{
cef_stream_reader_t* impl =
cef_stream_reader_create_for_file(fileName.c_str());
if(impl)
return CefStreamReaderCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefStreamReader> CefStreamReader::CreateForData(void *data,
size_t size)
{
cef_stream_reader_t* impl = cef_stream_reader_create_for_data(data, size);
if(impl)
return CefStreamReaderCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
size_t CefStreamReaderCToCpp::Read(void *ptr, size_t size, size_t n)
{
if(CEF_MEMBER_MISSING(struct_, read))
return 0;
return struct_->read(struct_, ptr, size, n);
}
int CefStreamReaderCToCpp::Seek(long offset, int whence)
{
if(CEF_MEMBER_MISSING(struct_, seek))
return 0;
return struct_->seek(struct_, offset, whence);
}
long CefStreamReaderCToCpp::Tell()
{
if(CEF_MEMBER_MISSING(struct_, tell))
return 0;
return struct_->tell(struct_);
}
int CefStreamReaderCToCpp::Eof()
{
if(CEF_MEMBER_MISSING(struct_, eof))
return 0;
return struct_->eof(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
cef_stream_reader_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,44 @@
// 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_CTOCPP_H
#define _STREAMREADER_CTOCPP_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 "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefStreamReaderCToCpp
: public CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
cef_stream_reader_t>
{
public:
CefStreamReaderCToCpp(cef_stream_reader_t* str)
: CefCToCpp<CefStreamReaderCToCpp, CefStreamReader, cef_stream_reader_t>(
str) {}
virtual ~CefStreamReaderCToCpp() {}
// CefStreamReader methods
virtual size_t Read(void *ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence);
virtual long Tell();
virtual int Eof();
};
#endif // USING_CEF_SHARED
#endif // _STREAMREADER_CTOCPP_H

View File

@ -1,48 +1,20 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "ctocpp/stream_ctocpp.h"
#include "ctocpp/stream_writer_ctocpp.h"
size_t CefStreamReaderCToCpp::Read(void *ptr, size_t size, size_t n)
{
if(CEF_MEMBER_MISSING(struct_, read))
return 0;
return struct_->read(struct_, ptr, size, n);
}
int CefStreamReaderCToCpp::Seek(long offset, int whence)
{
if(CEF_MEMBER_MISSING(struct_, seek))
return 0;
return struct_->seek(struct_, offset, whence);
}
long CefStreamReaderCToCpp::Tell()
{
if(CEF_MEMBER_MISSING(struct_, tell))
return 0;
return struct_->tell(struct_);
}
int CefStreamReaderCToCpp::Eof()
{
if(CEF_MEMBER_MISSING(struct_, eof))
return 0;
return struct_->eof(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
cef_stream_reader_t>::DebugObjCt = 0;
#endif
// VIRTUAL METHODS - Body may be edited by hand.
size_t CefStreamWriterCToCpp::Write(const void *ptr, size_t size, size_t n)
{
@ -76,7 +48,9 @@ int CefStreamWriterCToCpp::Flush()
return struct_->flush(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
cef_stream_writer_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,44 @@
// 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_CTOCPP_H
#define _STREAMWRITER_CTOCPP_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 "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefStreamWriterCToCpp
: public CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
cef_stream_writer_t>
{
public:
CefStreamWriterCToCpp(cef_stream_writer_t* str)
: CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter, cef_stream_writer_t>(
str) {}
virtual ~CefStreamWriterCToCpp() {}
// CefStreamWriter methods
virtual size_t Write(const void *ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence);
virtual long Tell();
virtual int Flush();
};
#endif // USING_CEF_SHARED
#endif // _STREAMWRITER_CTOCPP_H

View File

@ -1,17 +1,25 @@
// 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 "ctocpp/v8handler_ctocpp.h"
#include "cpptoc/v8value_cpptoc.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.
//
// ---------------------------------------------------------------------------
//
// 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 static and
// virtual method 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"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefV8HandlerCToCpp::Execute(const std::wstring& name,
CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, std::wstring& exception)
{
if(CEF_MEMBER_MISSING(struct_, execute))
return RV_CONTINUE;
@ -28,7 +36,8 @@ bool CefV8HandlerCToCpp::Execute(const std::wstring& name,
cef_string_t exceptionStr = NULL;
int rv = struct_->execute(struct_, name.c_str(),
CefV8ValueCppToC::Wrap(object), argsSize, argsStructPtr, &retvalStruct,
CefV8ValueCppToC::Wrap(object), argsSize,
const_cast<const cef_v8value_t**>(argsStructPtr), &retvalStruct,
&exceptionStr);
if(retvalStruct)
retval = CefV8ValueCppToC::Unwrap(retvalStruct);
@ -43,7 +52,9 @@ bool CefV8HandlerCToCpp::Execute(const std::wstring& name,
return rv;
}
#ifdef _DEBUG
long CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>::DebugObjCt
= 0;
long CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>::DebugObjCt =
0;
#endif

View File

@ -1,37 +1,41 @@
// 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_CTOCPP_H
#define _V8HANDLER_CTOCPP_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 _V8HANDLER_CTOCPP_H
#define _V8HANDLER_CTOCPP_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 "ctocpp.h"
// Wrap a C v8handler structure with a C++ v8handler class.
// This class may be instantiated and accessed DLL-side only.
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefV8HandlerCToCpp
: public CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>
{
public:
CefV8HandlerCToCpp(cef_v8handler_t* str)
: CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>(str) {}
virtual ~CefV8HandlerCToCpp() {}
public:
CefV8HandlerCToCpp(cef_v8handler_t* str)
: CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>(str) {}
virtual ~CefV8HandlerCToCpp() {}
// CefV8Handler methods
virtual bool Execute(const std::wstring& name,
CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
};
#endif // BUILDING_CEF_SHARED
#endif // _V8HANDLER_CTOCPP_H
virtual bool Execute(const std::wstring& name, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
};
#endif // BUILDING_CEF_SHARED
#endif // _V8HANDLER_CTOCPP_H

View File

@ -1,12 +1,108 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "../precompiled_libcef.h"
#include "cpptoc/base_cpptoc.h"
#include "cpptoc/v8handler_cpptoc.h"
#include "ctocpp/v8value_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefV8Value> CefV8Value::CreateUndefined()
{
cef_v8value_t* impl = cef_v8value_create_undefined();
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateNull()
{
cef_v8value_t* impl = cef_v8value_create_null();
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateBool(bool value)
{
cef_v8value_t* impl = cef_v8value_create_bool(value);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateInt(int value)
{
cef_v8value_t* impl = cef_v8value_create_int(value);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
{
cef_v8value_t* impl = cef_v8value_create_double(value);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateString(const std::wstring& value)
{
cef_v8value_t* impl = cef_v8value_create_string(value.c_str());
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateObject(CefRefPtr<CefBase> user_data)
{
cef_base_t* baseStruct = NULL;
if(user_data)
baseStruct = CefBaseCppToC::Wrap(user_data);
cef_v8value_t* impl = cef_v8value_create_object(baseStruct);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateArray()
{
cef_v8value_t* impl = cef_v8value_create_array();
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const std::wstring& name,
CefRefPtr<CefV8Handler> handler)
{
cef_v8handler_t* handlerStruct = NULL;
if(handler.get())
handlerStruct = CefV8HandlerCppToC::Wrap(handler);
cef_v8value_t* impl = cef_v8value_create_function(name.c_str(),
handlerStruct);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
bool CefV8ValueCToCpp::IsUndefined()
{
if(CEF_MEMBER_MISSING(struct_, is_undefined))
@ -171,7 +267,8 @@ CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(int index)
return NULL;
}
bool CefV8ValueCToCpp::SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value)
bool CefV8ValueCToCpp::SetValue(const std::wstring& key,
CefRefPtr<CefV8Value> value)
{
if(CEF_MEMBER_MISSING(struct_, set_value_bykey))
return false;
@ -254,9 +351,8 @@ CefRefPtr<CefV8Handler> CefV8ValueCToCpp::GetFunctionHandler()
}
bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
{
if(CEF_MEMBER_MISSING(struct_, execute_function))
return RV_CONTINUE;
@ -273,7 +369,8 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
cef_string_t exceptionStr = NULL;
int rv = struct_->execute_function(struct_, CefV8ValueCToCpp::Unwrap(object),
argsSize, argsStructPtr, &retvalStruct, &exceptionStr);
argsSize, const_cast<const cef_v8value_t**>(argsStructPtr), &retvalStruct,
&exceptionStr);
if(retvalStruct)
retval = CefV8ValueCToCpp::Wrap(retvalStruct);
if(exceptionStr) {
@ -291,3 +388,4 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
#ifdef _DEBUG
long CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>::DebugObjCt = 0;
#endif

View File

@ -1,29 +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 _V8VALUE_CTOCPP_H
#define _V8VALUE_CTOCPP_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 _V8VALUE_CTOCPP_H
#define _V8VALUE_CTOCPP_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 "ctocpp.h"
// Wrap a C v8value structure with a C++ v8value class.
// This class may be instantiated and accessed DLL-side only.
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefV8ValueCToCpp
: public CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>
{
public:
CefV8ValueCToCpp(cef_v8value_t* str)
: CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>(str) {}
virtual ~CefV8ValueCToCpp() {}
public:
CefV8ValueCToCpp(cef_v8value_t* str)
: CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>(str) {}
virtual ~CefV8ValueCToCpp() {}
// CefV8Value methods
virtual bool IsUndefined();
virtual bool IsNull();
@ -52,11 +58,10 @@ public:
virtual std::wstring GetFunctionName();
virtual CefRefPtr<CefV8Handler> GetFunctionHandler();
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
};
#endif // USING_CEF_SHARED
#endif // _V8VALUE_CTOCPP_H
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
};
#endif // USING_CEF_SHARED
#endif // _V8VALUE_CTOCPP_H

View File

@ -9,8 +9,11 @@
#include "cef_nplugin.h"
#include "cef_nplugin_capi.h"
#include "cpptoc/browser_cpptoc.h"
#include "cpptoc/post_data_cpptoc.h"
#include "cpptoc/post_data_element_cpptoc.h"
#include "cpptoc/request_cpptoc.h"
#include "cpptoc/stream_cpptoc.h"
#include "cpptoc/stream_reader_cpptoc.h"
#include "cpptoc/stream_writer_cpptoc.h"
#include "cpptoc/v8value_cpptoc.h"
#include "ctocpp/handler_ctocpp.h"
#include "ctocpp/v8handler_ctocpp.h"
@ -69,180 +72,6 @@ CEF_EXPORT int cef_register_extension(const wchar_t* extension_name,
return CefRegisterExtension(nameStr, codeStr, handlerPtr);
}
CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup,
cef_handler_t* handler, const wchar_t* url)
{
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_EXPORT cef_browser_t* cef_create_browser_sync(cef_window_info_t* windowInfo,
int popup,
cef_handler_t* handler,
const wchar_t* url)
{
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;
}
CEF_EXPORT cef_request_t* cef_create_request()
{
CefRefPtr<CefRequest> impl = CefRequest::CreateRequest();
if(impl.get())
return CefRequestCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_post_data_t* cef_create_post_data()
{
CefRefPtr<CefPostData> impl = CefPostData::CreatePostData();
if(impl.get())
return CefPostDataCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_post_data_element_t* cef_create_post_data_element()
{
CefRefPtr<CefPostDataElement> impl =
CefPostDataElement::CreatePostDataElement();
if(impl.get())
return CefPostDataElementCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_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_create_stream_reader_for_data(void *data,
size_t size)
{
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForData(data, size);
if(impl.get())
return CefStreamReaderCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_undefined()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateUndefined();
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_null()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateNull();
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_bool(int value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateBool(value?true:false);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_int(int value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateInt(value);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_double(double value)
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateDouble(value);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_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_create_v8value_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_create_v8value_array()
{
CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray();
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_create_v8value_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;
}
CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info)
{
CefPluginInfo pluginInfo;

View File

@ -254,6 +254,54 @@
RelativePath=".\cpptoc\frame_cpptoc.h"
>
</File>
<File
RelativePath=".\cpptoc\post_data_cpptoc.cc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="../precompiled_libcef.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="../precompiled_libcef.h"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\cpptoc\post_data_cpptoc.h"
>
</File>
<File
RelativePath=".\cpptoc\post_data_element_cpptoc.cc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="../precompiled_libcef.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="../precompiled_libcef.h"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\cpptoc\post_data_element_cpptoc.h"
>
</File>
<File
RelativePath=".\cpptoc\request_cpptoc.cc"
>
@ -279,7 +327,7 @@
>
</File>
<File
RelativePath=".\cpptoc\stream_cpptoc.cc"
RelativePath=".\cpptoc\stream_reader_cpptoc.cc"
>
<FileConfiguration
Name="Debug|Win32"
@ -299,7 +347,31 @@
</FileConfiguration>
</File>
<File
RelativePath=".\cpptoc\stream_cpptoc.h"
RelativePath=".\cpptoc\stream_reader_cpptoc.h"
>
</File>
<File
RelativePath=".\cpptoc\stream_writer_cpptoc.cc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="../precompiled_libcef.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="../precompiled_libcef.h"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\cpptoc\stream_writer_cpptoc.h"
>
</File>
<File

View File

@ -10,8 +10,11 @@
#include "../cpptoc/handler_cpptoc.h"
#include "../cpptoc/v8handler_cpptoc.h"
#include "../ctocpp/browser_ctocpp.h"
#include "../ctocpp/post_data_ctocpp.h"
#include "../ctocpp/post_data_element_ctocpp.h"
#include "../ctocpp/request_ctocpp.h"
#include "../ctocpp/stream_ctocpp.h"
#include "../ctocpp/stream_reader_ctocpp.h"
#include "../ctocpp/stream_writer_ctocpp.h"
#include "../ctocpp/v8value_ctocpp.h"
@ -52,149 +55,6 @@ bool CefRegisterExtension(const std::wstring& extension_name,
CefV8HandlerCppToC::Wrap(handler));
}
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url)
{
return cef_create_browser(&windowInfo, popup, CefHandlerCppToC::Wrap(handler),
url.c_str());
}
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url)
{
cef_browser_t* impl = cef_create_browser_sync(&windowInfo, popup,
CefHandlerCppToC::Wrap(handler), url.c_str());
if(impl)
return CefBrowserCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefRequest> CreateRequest()
{
cef_request_t* impl = cef_create_request();
if(impl)
return CefRequestCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefPostData> CreatePostData()
{
cef_post_data_t* impl = cef_create_post_data();
if(impl)
return CefPostDataCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefPostDataElement> CreatePostDataElement()
{
cef_post_data_element_t* impl = cef_create_post_data_element();
if(impl)
return CefPostDataElementCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(const std::wstring& fileName)
{
cef_stream_reader_t* impl =
cef_create_stream_reader_for_file(fileName.c_str());
if(impl)
return CefStreamReaderCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefStreamReader> CefStreamReader::CreateForData(void *data, size_t size)
{
cef_stream_reader_t* impl = cef_create_stream_reader_for_data(data, size);
if(impl)
return CefStreamReaderCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateUndefined()
{
cef_v8value_t* impl = cef_create_v8value_undefined();
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateNull()
{
cef_v8value_t* impl = cef_create_v8value_null();
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateBool(bool value)
{
cef_v8value_t* impl = cef_create_v8value_bool(value);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateInt(int value)
{
cef_v8value_t* impl = cef_create_v8value_int(value);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
{
cef_v8value_t* impl = cef_create_v8value_double(value);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateString(const std::wstring& value)
{
cef_v8value_t* impl = cef_create_v8value_string(value.c_str());
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateObject(CefRefPtr<CefBase> user_data)
{
cef_base_t* baseStruct = NULL;
if(user_data)
baseStruct = CefBaseCppToC::Wrap(user_data);
cef_v8value_t* impl = cef_create_v8value_object(baseStruct);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateArray()
{
cef_v8value_t* impl = cef_create_v8value_array();
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const std::wstring& name,
CefRefPtr<CefV8Handler> handler)
{
cef_v8handler_t* handlerStruct = NULL;
if(handler.get())
handlerStruct = CefV8HandlerCppToC::Wrap(handler);
cef_v8value_t* impl = cef_create_v8value_function(name.c_str(),
handlerStruct);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
}
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info)
{
cef_plugin_info_t pluginInfo;

View File

@ -173,6 +173,22 @@
RelativePath="..\ctocpp\frame_ctocpp.h"
>
</File>
<File
RelativePath="..\ctocpp\post_data_ctocpp.cc"
>
</File>
<File
RelativePath="..\ctocpp\post_data_ctocpp.h"
>
</File>
<File
RelativePath="..\ctocpp\post_data_element_ctocpp.cc"
>
</File>
<File
RelativePath="..\ctocpp\post_data_element_ctocpp.h"
>
</File>
<File
RelativePath="..\ctocpp\request_ctocpp.cc"
>
@ -182,11 +198,19 @@
>
</File>
<File
RelativePath="..\ctocpp\stream_ctocpp.cc"
RelativePath="..\ctocpp\stream_reader_ctocpp.cc"
>
</File>
<File
RelativePath="..\ctocpp\stream_ctocpp.h"
RelativePath="..\ctocpp\stream_reader_ctocpp.h"
>
</File>
<File
RelativePath="..\ctocpp\stream_writer_ctocpp.cc"
>
</File>
<File
RelativePath="..\ctocpp\stream_writer_ctocpp.h"
>
</File>
<File

View File

@ -42,7 +42,7 @@ public:
// the method was handled.
virtual bool Execute(const std::wstring& name,
CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
{
@ -285,7 +285,7 @@ public:
// the method was handled.
virtual bool Execute(const std::wstring& name,
CefRefPtr<CefV8Value> object,
CefV8ValueList& arguments,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
{

1316
tools/cef_parser.py Normal file

File diff suppressed because it is too large Load Diff

194
tools/make_capi_header.py Normal file
View File

@ -0,0 +1,194 @@
# 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.
from cef_parser import *
def make_capi_global_funcs(funcs, defined_names, translate_map, indent):
result = ''
first = True
for func in funcs:
comment = func.get_comment()
if first or len(comment) > 0:
result += '\n'+format_comment(comment, indent, translate_map);
if func.get_retval().get_type().is_result_string():
result += indent+'// The resulting string must be freed by calling cef_string_free().\n'
result += wrap_code(indent+'CEF_EXPORT '+
func.get_capi_proto(defined_names)+';')
if first:
first = False
return result
def make_capi_member_funcs(funcs, defined_names, translate_map, indent):
result = ''
first = True
for func in funcs:
comment = func.get_comment()
if first or len(comment) > 0:
result += '\n'+format_comment(comment, indent, translate_map)
if func.get_retval().get_type().is_result_string():
result += indent+'// The resulting string must be freed by calling cef_string_free().\n'
parts = func.get_capi_parts()
result += wrap_code(indent+parts['retval']+' (CEF_CALLBACK *'+
parts['name']+')('+
string.join(parts['args'], ', ')+');')
if first:
first = False
return result
def make_capi_header(header):
# structure names that have already been defined
defined_names = header.get_defined_structs()
# map of strings that will be changed in C++ comments
translate_map = header.get_capi_translations()
# header string
result = \
"""// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// 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 _CEF_CAPI_H
#define _CEF_CAPI_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_export.h"
#include "cef_string.h"
#include "cef_string_list.h"
#include "cef_string_map.h"
#include "cef_types.h"
"""
# output global functions
result += make_capi_global_funcs(header.get_funcs(), defined_names,
translate_map, '')
# before classes string
result += \
"""
typedef struct _cef_base_t
{
// Size of the data structure.
size_t size;
// Increment the reference count.
int (CEF_CALLBACK *add_ref)(struct _cef_base_t* self);
// Decrement the reference count. Delete this object when no references
// remain.
int (CEF_CALLBACK *release)(struct _cef_base_t* self);
// Returns the current number of references.
int (CEF_CALLBACK *get_refct)(struct _cef_base_t* self);
} cef_base_t;
// Check that the structure |s|, which is defined with a cef_base_t member named
// |base|, is large enough to contain the specified member |f|.
#define CEF_MEMBER_EXISTS(s, f) \\
((int)&((s)->f) - (int)(s) + sizeof((s)->f) <= (s)->base.size)
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
"""
# output classes
classes = header.get_classes()
for cls in classes:
# virtual functions are inside the structure
classname = cls.get_capi_name()
result += '\n'+format_comment(cls.get_comment(), '', translate_map);
result += 'typedef struct _'+classname+ \
'\n{\n // Base structure.\n cef_base_t base;\n'
funcs = cls.get_virtual_funcs()
result += make_capi_member_funcs(funcs, defined_names,
translate_map, ' ')
result += '\n} '+classname+';\n\n'
defined_names.append(cls.get_capi_name())
# static functions become global
funcs = cls.get_static_funcs()
if len(funcs) > 0:
result += make_capi_global_funcs(funcs, defined_names,
translate_map, '')+'\n'
# footer string
result += \
"""
#ifdef __cplusplus
}
#endif
#endif // _CEF_CAPI_H
"""
return result
def write_capi_header(header, file, backup):
if file_exists(file):
oldcontents = read_file(file)
else:
oldcontents = ''
newcontents = make_capi_header(header)
if newcontents != oldcontents:
if backup and oldcontents != '':
backup_file(file)
write_file(file, newcontents)
return True
return False
# test the module
if __name__ == "__main__":
import sys
# verify that the correct number of command-line arguments are provided
if len(sys.argv) < 2:
sys.stderr.write('Usage: '+sys.argv[0]+' <infile>')
sys.exit()
# create the header object
header = obj_header(sys.argv[1])
# dump the result to stdout
sys.stdout.write(make_capi_header(header))

106
tools/make_cpptoc_header.py Normal file
View File

@ -0,0 +1,106 @@
# 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.
from cef_parser import *
def make_cpptoc_header(header, clsname):
cls = header.get_class(clsname)
if cls is None:
raise Exception('Class does not exist: '+clsname)
dllside = cls.is_library_side()
defname = string.upper(clsname[3:])
capiname = cls.get_capi_name()
result = \
"""// 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.
//
"""
result += '#ifndef _'+defname+'_CPPTOC_H\n'+ \
'#define _'+defname+'_CPPTOC_H\n'
if dllside:
result += """
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
"""
else:
result += """
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
"""
result += """
#include "cef.h"
#include "cef_capi.h"
#include "cpptoc.h"
// Wrap a C++ class with a C structure.
"""
if dllside:
result += '// This class may be instantiated and accessed DLL-side only.\n'
else:
result += '// This class may be instantiated and accessed wrapper-side only.\n'
result += 'class '+clsname+'CppToC\n'+ \
' : public CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>\n'+ \
'{\n'+ \
'public:\n'+ \
' '+clsname+'CppToC('+clsname+'* cls);\n'+ \
' virtual ~'+clsname+'CppToC() {}\n'+ \
'};\n\n'
if dllside:
result += '#endif // BUILDING_CEF_SHARED\n'
else:
result += '#endif // USING_CEF_SHARED\n'
result += '#endif // _'+defname+'_CPPTOC_H\n'
return wrap_code(result)
def write_cpptoc_header(header, clsname, dir, backup):
file = dir+'\\'+get_capi_name(clsname[3:], False)+'_cpptoc.h'
if file_exists(file):
oldcontents = read_file(file)
else:
oldcontents = ''
newcontents = make_cpptoc_header(header, clsname)
if newcontents != oldcontents:
if backup and oldcontents != '':
backup_file(file)
write_file(file, newcontents)
return True
return False
# test the module
if __name__ == "__main__":
import sys
# verify that the correct number of command-line arguments are provided
if len(sys.argv) < 3:
sys.stderr.write('Usage: '+sys.argv[0]+' <infile> <classname>')
sys.exit()
# create the header object
header = obj_header(sys.argv[1])
# dump the result to stdout
sys.stdout.write(make_cpptoc_header(header, sys.argv[2]))

184
tools/make_cpptoc_impl.py Normal file
View File

@ -0,0 +1,184 @@
# 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.
from cef_parser import *
def make_cpptoc_impl_proto(name, func, parts):
if isinstance(func, obj_function_virtual):
proto = parts['retval']+' CEF_CALLBACK'
else:
proto = 'CEF_EXPORT '+parts['retval']
proto += ' '+name+'('+string.join(parts['args'], ', ')+')'
return wrap_code(proto)
def make_cpptoc_impl_existing(name, func, impl, defined_names):
# retrieve the C API prototype parts
parts = func.get_capi_parts(defined_names)
changes = format_translation_changes(impl, parts)
if len(changes) > 0:
notify('Changed prototype for '+name)
return make_cpptoc_impl_proto(name, func, parts)+'{'+ \
changes+impl['body']+'\n}\n\n'
return result
def make_cpptoc_impl_new(name, func, defined_names):
notify('Added implementation for '+name)
# retrieve the C API prototype parts
parts = func.get_capi_parts(defined_names)
result = make_cpptoc_impl_proto(name, func, parts)+'{'
result += '\n // BEGIN DELETE BEFORE MODIFYING'
result += '\n // AUTO-GENERATED CONTENT'
result += '\n #pragma message("Warning: "__FILE__": '+name+' is not implemented")'
result += '\n // END DELETE BEFORE MODIFYING'
result += '\n}\n\n'
return result
def make_cpptoc_impl(header, clsname, impl):
# structure names that have already been defined
defined_names = header.get_defined_structs()
# retrieve the class and populate the defined names
cls = header.get_class(clsname, defined_names)
if cls is None:
raise Exception('Class does not exist: '+clsname)
defname = string.upper(clsname[3:])
capiname = cls.get_capi_name()
prefixname = get_capi_name(clsname[3:], False)
# retrieve the existing virtual function implementations
existing = get_function_impls(impl, 'CEF_CALLBACK')
# generate virtual functions
virtualimpl = ''
funcs = cls.get_virtual_funcs()
for func in funcs:
name = prefixname+'_'+func.get_capi_name()
value = get_next_function_impl(existing, name)
if not value is None \
and value['body'].find('// AUTO-GEN') < 0:
# an implementation exists that was not auto-generated
virtualimpl += make_cpptoc_impl_existing(name, func, value,
defined_names)
else:
virtualimpl += make_cpptoc_impl_new(name, func, defined_names)
if len(virtualimpl) > 0:
virtualimpl = '\n// MEMBER FUNCTIONS - Body may be edited by hand.\n\n'+virtualimpl
# the current class is already defined for static functions
defined_names.append(cls.get_capi_name())
# retrieve the existing static function implementations
existing = get_function_impls(impl, 'CEF_EXPORT')
# generate static functions
staticimpl = ''
funcs = cls.get_static_funcs()
for func in funcs:
name = func.get_capi_name()
value = get_next_function_impl(existing, name)
if not value is None \
and value['body'].find('// AUTO-GENERATED CONTENT') < 0:
# an implementation exists that was not auto-generated
staticimpl += make_cpptoc_impl_existing(name, func, value,
defined_names)
else:
staticimpl += make_cpptoc_impl_new(name, func, defined_names)
if len(staticimpl) > 0:
staticimpl = '\n// GLOBAL FUNCTIONS - Body may be edited by hand.\n\n'+staticimpl
resultingimpl = staticimpl + virtualimpl
# determine what includes are required by identifying what translation
# classes are being used
includes = format_translation_includes(resultingimpl)
# build the final output
result = \
"""// 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.
//
"""
result += includes+'\n'+resultingimpl+'\n'
const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \
clsname+'CppToC::'+clsname+'CppToC('+clsname+'* cls)\n'+ \
' : CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>(cls)\n'+ \
'{\n';
funcs = cls.get_virtual_funcs()
for func in funcs:
name = func.get_capi_name()
const += ' struct_.struct_.'+name+' = '+prefixname+'_'+name+';\n'
const += '}\n\n'+ \
'#ifdef _DEBUG\n'+ \
'long CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>::DebugObjCt = 0;\n'+ \
'#endif\n'
result += wrap_code(const)
return result
def write_cpptoc_impl(header, clsname, dir, backup):
file = dir+'\\'+get_capi_name(clsname[3:], False)+'_cpptoc.cc'
if file_exists(file):
oldcontents = read_file(file)
else:
oldcontents = ''
newcontents = make_cpptoc_impl(header, clsname, oldcontents)
if newcontents != oldcontents:
if backup and oldcontents != '':
backup_file(file)
write_file(file, newcontents)
return True
return False
# test the module
if __name__ == "__main__":
import sys
# verify that the correct number of command-line arguments are provided
if len(sys.argv) < 4:
sys.stderr.write('Usage: '+sys.argv[0]+' <infile> <classname> <existing_impl>')
sys.exit()
# create the header object
header = obj_header(sys.argv[1])
# read the existing implementation file into memory
try:
f = open(sys.argv[3], 'r')
data = f.read()
except IOError, (errno, strerror):
raise Exception('Failed to read file '+sys.argv[3]+': '+strerror)
else:
f.close()
# dump the result to stdout
sys.stdout.write(make_cpptoc_impl(header, sys.argv[2], data))

114
tools/make_ctocpp_header.py Normal file
View File

@ -0,0 +1,114 @@
# 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.
from cef_parser import *
def make_ctocpp_header(header, clsname):
cls = header.get_class(clsname)
if cls is None:
raise Exception('Class does not exist: '+clsname)
clientside = cls.is_client_side()
defname = string.upper(clsname[3:])
capiname = cls.get_capi_name()
result = \
"""// 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.
//
"""
result += '#ifndef _'+defname+'_CTOCPP_H\n'+ \
'#define _'+defname+'_CTOCPP_H\n'
if clientside:
result += """
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
"""
else:
result += """
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
"""
result += """
#include "cef.h"
#include "cef_capi.h"
#include "ctocpp.h"
// Wrap a C structure with a C++ class.
"""
if clientside:
result += '// This class may be instantiated and accessed DLL-side only.\n'
else:
result += '// This class may be instantiated and accessed wrapper-side only.\n'
result += 'class '+clsname+'CToCpp\n'+ \
' : public CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>\n'+ \
'{\n'+ \
'public:\n'+ \
' '+clsname+'CToCpp('+capiname+'* str)\n'+ \
' : CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>(str) {}\n'+ \
' virtual ~'+clsname+'CToCpp() {}\n\n'+ \
' // '+clsname+' methods\n';
funcs = cls.get_virtual_funcs()
for func in funcs:
result += ' virtual '+func.get_cpp_proto()+';\n'
result += '};\n\n'
if clientside:
result += '#endif // BUILDING_CEF_SHARED\n'
else:
result += '#endif // USING_CEF_SHARED\n'
result += '#endif // _'+defname+'_CTOCPP_H\n'
return wrap_code(result)
def write_ctocpp_header(header, clsname, dir, backup):
file = dir+'\\'+get_capi_name(clsname[3:], False)+'_ctocpp.h'
if file_exists(file):
oldcontents = read_file(file)
else:
oldcontents = ''
newcontents = make_ctocpp_header(header, clsname)
if newcontents != oldcontents:
if backup and oldcontents != '':
backup_file(file)
write_file(file, newcontents)
return True
return False
# test the module
if __name__ == "__main__":
import sys
# verify that the correct number of command-line arguments are provided
if len(sys.argv) < 3:
sys.stderr.write('Usage: '+sys.argv[0]+' <infile> <classname>')
sys.exit()
# create the header object
header = obj_header(sys.argv[1])
# dump the result to stdout
sys.stdout.write(make_ctocpp_header(header, sys.argv[2]))

167
tools/make_ctocpp_impl.py Normal file
View File

@ -0,0 +1,167 @@
# 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.
from cef_parser import *
def make_ctocpp_impl_proto(clsname, name, func, parts):
proto = parts['retval']+' '+clsname
if isinstance(func, obj_function_virtual):
proto += 'CToCpp'
proto += '::'+name+'('+string.join(parts['args'], ', ')+')'
return wrap_code(proto)
def make_ctocpp_impl_existing(clsname, name, func, impl):
# retrieve the C++ prototype parts
parts = func.get_cpp_parts(True)
changes = format_translation_changes(impl, parts)
if len(changes) > 0:
if isinstance(func, obj_function_virtual):
notify('Changed prototype for '+clsname+'CToCpp::'+name)
else:
notify('Changed prototype for '+clsname+'::'+name)
return make_ctocpp_impl_proto(clsname, name, func, parts)+'{'+ \
changes+impl['body']+'\n}\n\n'
def make_ctocpp_impl_new(clsname, name, func):
if isinstance(func, obj_function_virtual):
notify('Added implementation for '+clsname+'CToCpp::'+name)
else:
notify('Added implementation for '+clsname+'::'+name)
# retrieve the C++ prototype parts
parts = func.get_cpp_parts(True)
result = make_ctocpp_impl_proto(clsname, name, func, parts)+'{'
result += '\n // BEGIN DELETE BEFORE MODIFYING'
result += '\n // AUTO-GENERATED CONTENT'
result += '\n #pragma message("Warning: "__FILE__": '+name+' is not implemented")'
result += '\n // END DELETE BEFORE MODIFYING'
result += '\n}\n\n'
return result
def make_ctocpp_impl(header, clsname, impl):
cls = header.get_class(clsname)
if cls is None:
raise Exception('Class does not exist: '+clsname)
capiname = cls.get_capi_name()
# retrieve the existing virtual function implementations
existing = get_function_impls(impl, clsname+'CToCpp::')
# generate virtual functions
virtualimpl = ''
funcs = cls.get_virtual_funcs()
for func in funcs:
name = func.get_name()
value = get_next_function_impl(existing, name)
if not value is None \
and value['body'].find('// AUTO-GEN') < 0:
# an implementation exists that was not auto-generated
virtualimpl += make_ctocpp_impl_existing(clsname, name, func,
value)
else:
virtualimpl += make_ctocpp_impl_new(clsname, name, func)
if len(virtualimpl) > 0:
virtualimpl = '\n// VIRTUAL METHODS - Body may be edited by hand.\n\n'+virtualimpl
# retrieve the existing static function implementations
existing = get_function_impls(impl, clsname+'::')
# generate static functions
staticimpl = ''
funcs = cls.get_static_funcs()
for func in funcs:
name = func.get_name()
value = get_next_function_impl(existing, name)
if not value is None \
and value['body'].find('// AUTO-GENERATED CONTENT') < 0:
# an implementation exists that was not auto-generated
staticimpl += make_ctocpp_impl_existing(clsname, name, func,
value)
else:
staticimpl += make_ctocpp_impl_new(clsname, name, func)
if len(staticimpl) > 0:
staticimpl = '\n// STATIC METHODS - Body may be edited by hand.\n\n'+staticimpl
resultingimpl = staticimpl + virtualimpl
# determine what includes are required by identifying what translation
# classes are being used
includes = format_translation_includes(resultingimpl)
# build the final output
result = \
"""// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
"""
result += includes+'\n'+resultingimpl+'\n'
result += wrap_code('#ifdef _DEBUG\n'+ \
'long CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>::DebugObjCt = 0;\n'+ \
'#endif\n')
return result
def write_ctocpp_impl(header, clsname, dir, backup):
file = dir+'\\'+get_capi_name(clsname[3:], False)+'_ctocpp.cc'
if file_exists(file):
oldcontents = read_file(file)
else:
oldcontents = ''
newcontents = make_ctocpp_impl(header, clsname, oldcontents)
if newcontents != oldcontents:
if backup and oldcontents != '':
backup_file(file)
write_file(file, newcontents)
return True
return False
# test the module
if __name__ == "__main__":
import sys
# verify that the correct number of command-line arguments are provided
if len(sys.argv) < 4:
sys.stderr.write('Usage: '+sys.argv[0]+' <infile> <classname> <existing_impl>')
sys.exit()
# create the header object
header = obj_header(sys.argv[1])
# read the existing implementation file into memory
try:
f = open(sys.argv[3], 'r')
data = f.read()
except IOError, (errno, strerror):
raise Exception('Failed to read file '+sys.argv[3]+': '+strerror)
else:
f.close()
# dump the result to stdout
sys.stdout.write(make_ctocpp_impl(header, sys.argv[2], data))

248
tools/translator.README.txt Normal file
View File

@ -0,0 +1,248 @@
Chromium Embedded Framework (CEF) Translator Tool -- translator.py
-------------------------------------------------------------------------------
Document Last Updated: June 20, 2009
OVERVIEW
--------
The CEF translator tool automatically generates CEF source code based on the
contents of the CEF header file (cef.h). The generated source code includes the
main C API header file (cef_capi.h) and all files in the libcef_dll/cpptoc and
libcef_dll/ctocpp directories.
If any differences are detected between the new translator-generated output and
the file that currently exists on disk a backup of the existing file will be
created before the new file is written (this behavior can be controlled using
a command-line switch -- see 'translator.py -h' for more information). Header
files (*.h) are completely generated by the translator and should never be
edited by hand. Implementation files (*.cc) contain user-created content within
method and function body blocks. The user-created content is extracted from the
existing file and inserted into the new translator-generated file. Any
differences between existing method/function prototypes and new method/function
prototypes will be noted as a warning in new output file.
// WARNING - CHANGED ATTRIBUTES
// REMOVED: const wchar_t* key
// ADDED: int index
// WARNING - CHANGED RETURN VALUE
// WAS: void
// NOW: int
#pragma message("Warning: "__FILE__": MyFunction prototype has changed")
Place-holder implementations will be added in the new output file for any
methods/functions that exist in the CEF header file but did not exist in the
current on-disk implementation file. Each time the translator re-generates the
implementation file it will warn if place-holder implementations exist. Delete
the indicated portion of the generated code after adding the implementation by
hand.
size_t CEF_CALLBACK frame_new_func(struct _cef_frame_t* self)
{
// BEGIN DELETE BEFORE MODIFYING
// AUTO-GENERATED CONTENT
#pragma message("Warning: "__FILE__": frame_new_func is not implemented")
// END DELETE BEFORE MODIFYING
}
The 'translator.bat' file can be used to run the translator tool with command-
line arguments that match the default CEF directory structure and output
options. Run 'translator.py -h' for a complete list of available command-line
arguments.
HEADER ATTRIBUTES
-----------------
Comment-based attribute tags are added before each function, class and method
definition in the CEF header file to provide the translator with additional
information about how the output should be generated. The attribute tags must
be in the form of a comma-delimited list of name=value pairs. Attribute names
and values must contain only alpha-numeric characters, numbers and underscores,
and must all exist on a single line.
/*--cef(name1=value1,name2=value2,name3=value3)--*/
Supported method attributes:
capi_name=[string] (Optional) Force a specific output name for the
resulting C API function.
Supported class attributes:
source=[library|client] (Required) Indicates whether the class
implementation is provided by the library or the
client. This effects the generation of guard
blocks in the cpptoc and ctocpp header files.
TRANSLATION RULES
-----------------
All C++ names in the CEF header file are written in CamelCaps format and all
C API translations are generated in lowercase_underscore format.
Translating Classes and Methods
-------------------------------
Class names and global function names must be prefixed with the 'Cef' string.
Global function translation
C++: void CefShutdown()
C API: void cef_shutdown()
The translation of a C++ class name to a C API structure name is prefixed with
'_' and postfixed with '_t'. A typedef of the C API structure to a value
without the prefixed '_' is also provided and may be used interchangeably.
Class name translation
C++: class CefPostData
C API: typedef struct _cef_post_data_t { ... } cef_post_data_t
The translation of a C++ virtual class method to a C API member function adds a
'self' structure pointer as the first parameter. This will always be a pointer
to the structure that contains the member function.
Virtual method translation
C++: virtual void SetFocus(bool enable)
C API: void set_focus(struct _cef_browser_t* self, int enable)
The translation of a C++ static class method to a C API global function
is prefixed with 'cef_classname_' where 'classname' is the
lowercase_underscore name of the class that contains the static method. Any
repeat of 'classname' in the function name is removed.
Static method translation
C++: static CefRefPtr<CefRequest> CreateRequest()
C API: struct _cef_request_t* cef_request_create()
Translating Data Types
----------------------
Data types that are available in both C++ and C are left unchanged. This
includes the 'double', 'int', 'long', 'size_t' and 'void' built-in types. Other
data types have differing levels of support as indicated below. The translation
tool will terminate with an exception if it encounters a data type
that it cannot translate.
Boolean type translation (argument or return value):
C++: bool
C API: int
String const by reference type translation (argument only)
C++: const std::wstring& value
C API: const wchar_t* value
String non-const by reference type translation (argument only)
C++: std::wstring& value
C API (result must be freed by the user):
cef_string_t* value
String non-const by reference type translation (return value only)
C++: std::wstring
C API (result must be freed by the user):
cef_string_t
Smart pointer type translation (argument or return value)
C++: CefRefPtr<CefBrowser>
C API: cef_browser_t*
Smart pointer by reference type translation (argument only)
C++: CefRefPtr<CefBrowser>& value
C API: cef_browser_t** value
String vector by reference type translation (argument only)
C++: std::vector<std::wstring>& value
C API (must be allocated and freed by the user):
cef_string_list_t value
Non-string vector non-const by reference type translation (argument only)
C++: std::vector<CefRefPtr<CefPostDataElement>>& elements
C API (changes the function prototype):
cef_post_data_element_t* func(..., int elementIndex, ...)
Non-string vector const by reference type translation (argument only)
C++: const std::vector<CefRefPtr<CefV8Value>>& arguments
C API (changes the function prototype):
... func(..., size_t argumentCount,
const struct _cef_v8value_t** arguments, ...)
String-to-string map by reference type translation (argument only)
C++: std::map<std::wstring,std::wstring>& value
C API (must be allocated and freed by the user):
cef_string_map_t value
Translating Comments
--------------------
Comments from the CEF header file are reproduced in the C API header file with
any referenced C++ types and terminology changed to reflect C API types and
terminology.
C++:
// Create a new CefV8Value object of the specified type. These methods
// should only be called from within the JavaScript context -- either in a
// CefV8Handler::Execute() callback or a CefHandler::HandleJSBinding()
// callback.
C API:
// Create a new cef_v8value_t object of the specified type. These functions
// should only be called from within the JavaScript context -- either in a
// cef_v8handler_t::execute() callback or a cef_handler_t::handle_jsbinding()
// callback.
Situations where the user is responsible for freeing strings allocated and
returned by the library are also noted by comments in the C API header file.
C API:
// The resulting string must be freed by calling cef_string_free().
A comment must occur immediately before the function, class or method that it
documents with no extra space in between. Comments may span multiple lines
but each line must start with the '//' comment identifier.
C++:
// Set focus for the browser window. If |enable| is true focus will be set
// to the window. Otherwise, focus will be removed.
/*--cef()--*/
virtual void SetFocus(bool enable) =0;
If two comments are separated by an empty line it will be assumed that the
higher comment represents a section header and additional space will be added
before it in the translated output.
C++:
// ARRAY METHODS - These methods are only available on arrays.
// Returns the number of elements in the array.
/*--cef()--*/
virtual int GetArrayLength() =0;
Empty lines and lines with the comment identifier but no content are considered
paragraph breaks for the purposes of wrapping the translated text. Any content
indented more than one space is reproduced as-is without content translation
or wrapping.
C++:
// Register a new V8 extension with the specified JavaScript extension code and
// handler. Functions implemented by the handler are prototyped using the
// keyword 'native'. The calling of a native function is restricted to the scope
// in which the prototype of the native function is defined.
//
// Example JavaScript extension code:
//
// // create the 'example' global object if it doesn't already exist.
// if (!example)
// example = {};
WORK REMAINING
--------------
o Generate place-holder implementations for C++ global functions.
o Automatically generate some function implementations based on an analysis of
the function prototype.

3
tools/translator.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
..\..\third_party\python_24\python.exe translator.py --cpp-header ..\include\cef.h --capi-header ..\include\cef_capi.h --cpptoc-dir ..\libcef_dll\cpptoc --ctocpp-dir ..\libcef_dll\ctocpp
pause

130
tools/translator.py Normal file
View File

@ -0,0 +1,130 @@
# 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.
import sys
from cef_parser import *
from make_capi_header import *
from make_cpptoc_header import *
from make_cpptoc_impl import *
from make_ctocpp_header import *
from make_ctocpp_impl import *
from optparse import OptionParser
# cannot be loaded as a module
if __name__ != "__main__":
sys.stderr.write('This file cannot be loaded as a module!')
sys.exit()
# parse command-line options
disc = """
This utility generates files for the CEF C++ to C API translation layer.
"""
parser = OptionParser(description=disc)
parser.add_option('--cpp-header', dest='cppheader', metavar='FILE',
help='source CEF C++ header file [required]')
parser.add_option('--capi-header', dest='capiheader', metavar='FILE',
help='output CEF C API header file')
parser.add_option('--cpptoc-dir', dest='cpptocdir', metavar='DIR',
help='input/output directory for CppToC translations')
parser.add_option('--ctocpp-dir', dest='ctocppdir', metavar='DIR',
help='input/output directory for CppToC translations')
parser.add_option('--no-cpptoc-header',
action='store_true', dest='nocpptocheader', default=False,
help='do not output the CppToC headers')
parser.add_option('--no-cpptoc-impl',
action='store_true', dest='nocpptocimpl', default=False,
help='do not output the CppToC implementations')
parser.add_option('--no-ctocpp-header',
action='store_true', dest='noctocppheader', default=False,
help='do not output the CToCpp headers')
parser.add_option('--no-ctocpp-impl',
action='store_true', dest='noctocppimpl', default=False,
help='do not output the CToCpp implementations')
parser.add_option('--no-backup',
action='store_true', dest='nobackup', default=False,
help='do not create a backup of modified files')
parser.add_option('-c', '--classes', dest='classes', action='append',
help='only translate the specified classes')
parser.add_option('-q', '--quiet',
action='store_true', dest='quiet', default=False,
help='do not output detailed status information')
(options, args) = parser.parse_args()
# the cppheader option is required
if options.cppheader is None:
parser.print_help(sys.stdout)
sys.exit()
# make sure the header exists
if not file_exists(options.cppheader):
sys.stderr.write('File '+options.cppheader+' does not exist.')
sys.exit()
# create the header object
if not options.quiet:
sys.stdout.write('Parsing '+options.cppheader+'...\n')
header = obj_header(options.cppheader)
writect = 0
if not options.capiheader is None:
#output the C API header
if not options.quiet:
sys.stdout.write('Generating C API header...\n')
writect += write_capi_header(header, options.capiheader,
not options.nobackup)
# build the list of classes to parse
allclasses = header.get_class_names()
if not options.classes is None:
for cls in options.classes:
if not cls in allclasses:
sys.stderr.write('ERROR: Unknown class: '+cls)
sys.exit()
classes = options.classes
else:
classes = allclasses
classes = sorted(classes)
if not options.cpptocdir is None:
#output CppToC files
if not options.quiet:
sys.stdout.write('In CppToC directory '+options.cpptocdir+'...\n')
for cls in classes:
if not options.nocpptocheader:
if not options.quiet:
sys.stdout.write('Generating '+cls+'CppToC header...\n')
writect += write_cpptoc_header(header, cls, options.cpptocdir,
not options.nobackup)
if not options.nocpptocimpl:
if not options.quiet:
sys.stdout.write('Generating '+cls+'CppToC implementation...\n')
writect += write_cpptoc_impl(header, cls, options.cpptocdir,
not options.nobackup)
if not options.ctocppdir is None:
#output CppToC files
if not options.quiet:
sys.stdout.write('In CToCpp directory '+options.ctocppdir+'...\n')
for cls in classes:
if not options.nocpptocheader:
if not options.quiet:
sys.stdout.write('Generating '+cls+'CToCpp header...\n')
writect += write_ctocpp_header(header, cls, options.ctocppdir,
not options.nobackup)
if not options.nocpptocimpl:
if not options.quiet:
sys.stdout.write('Generating '+cls+'CToCpp implementation...\n')
writect += write_ctocpp_impl(header, cls, options.ctocppdir,
not options.nobackup)
if not options.quiet:
sys.stdout.write('Done - Wrote '+str(writect)+' files.\n')