From 8a04c0f0c1179b598806eb63308bffd3b460eec7 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Sat, 20 Jun 2009 22:09:28 +0000 Subject: [PATCH] - 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 --- include/cef.h | 317 ++-- include/cef_capi.h | 880 +++++------ libcef/v8_impl.cc | 6 +- libcef/v8_impl.h | 2 +- libcef_dll/cpptoc/base_cpptoc.h | 143 ++ libcef_dll/cpptoc/browser_cpptoc.cc | 346 +++-- libcef_dll/cpptoc/browser_cpptoc.h | 53 +- libcef_dll/cpptoc/cpptoc.h | 406 ++--- libcef_dll/cpptoc/frame_cpptoc.cc | 477 +++--- libcef_dll/cpptoc/frame_cpptoc.h | 53 +- libcef_dll/cpptoc/handler_cpptoc.cc | 813 +++++----- libcef_dll/cpptoc/handler_cpptoc.h | 53 +- libcef_dll/cpptoc/post_data_cpptoc.cc | 107 ++ libcef_dll/cpptoc/post_data_cpptoc.h | 34 + libcef_dll/cpptoc/post_data_element_cpptoc.cc | 129 ++ libcef_dll/cpptoc/post_data_element_cpptoc.h | 35 + libcef_dll/cpptoc/request_cpptoc.cc | 359 ++--- libcef_dll/cpptoc/request_cpptoc.h | 76 +- libcef_dll/cpptoc/stream_cpptoc.cc | 116 -- libcef_dll/cpptoc/stream_reader_cpptoc.cc | 98 ++ ...stream_cpptoc.h => stream_reader_cpptoc.h} | 67 +- libcef_dll/cpptoc/stream_writer_cpptoc.cc | 74 + libcef_dll/cpptoc/stream_writer_cpptoc.h | 35 + libcef_dll/cpptoc/v8handler_cpptoc.cc | 104 +- libcef_dll/cpptoc/v8handler_cpptoc.h | 53 +- libcef_dll/cpptoc/v8value_cpptoc.cc | 721 +++++---- libcef_dll/cpptoc/v8value_cpptoc.h | 53 +- libcef_dll/ctocpp/base_ctocpp.h | 95 ++ libcef_dll/ctocpp/browser_ctocpp.cc | 44 +- libcef_dll/ctocpp/browser_ctocpp.h | 60 +- libcef_dll/ctocpp/ctocpp.h | 272 ++-- libcef_dll/ctocpp/frame_ctocpp.cc | 37 +- libcef_dll/ctocpp/frame_ctocpp.h | 73 +- libcef_dll/ctocpp/handler_ctocpp.cc | 70 +- libcef_dll/ctocpp/handler_ctocpp.h | 140 +- libcef_dll/ctocpp/post_data_ctocpp.cc | 86 ++ libcef_dll/ctocpp/post_data_ctocpp.h | 43 + libcef_dll/ctocpp/post_data_element_ctocpp.cc | 98 ++ libcef_dll/ctocpp/post_data_element_ctocpp.h | 47 + libcef_dll/ctocpp/request_ctocpp.cc | 165 +-- libcef_dll/ctocpp/request_ctocpp.h | 106 +- libcef_dll/ctocpp/stream_ctocpp.h | 58 - libcef_dll/ctocpp/stream_reader_ctocpp.cc | 78 + libcef_dll/ctocpp/stream_reader_ctocpp.h | 44 + ...ream_ctocpp.cc => stream_writer_ctocpp.cc} | 58 +- libcef_dll/ctocpp/stream_writer_ctocpp.h | 44 + libcef_dll/ctocpp/v8handler_ctocpp.cc | 39 +- libcef_dll/ctocpp/v8handler_ctocpp.h | 66 +- libcef_dll/ctocpp/v8value_ctocpp.cc | 116 +- libcef_dll/ctocpp/v8value_ctocpp.h | 63 +- libcef_dll/libcef_dll.cc | 179 +-- libcef_dll/libcef_dll.vcproj | 76 +- libcef_dll/wrapper/libcef_dll_wrapper.cc | 148 +- libcef_dll/wrapper/libcef_dll_wrapper.vcproj | 28 +- tests/cefclient/cefclient.cpp | 4 +- tools/cef_parser.py | 1316 +++++++++++++++++ tools/make_capi_header.py | 194 +++ tools/make_cpptoc_header.py | 106 ++ tools/make_cpptoc_impl.py | 184 +++ tools/make_ctocpp_header.py | 114 ++ tools/make_ctocpp_impl.py | 167 +++ tools/translator.README.txt | 248 ++++ tools/translator.bat | 3 + tools/translator.py | 130 ++ 64 files changed, 6830 insertions(+), 3579 deletions(-) create mode 100644 libcef_dll/cpptoc/base_cpptoc.h create mode 100644 libcef_dll/cpptoc/post_data_cpptoc.cc create mode 100644 libcef_dll/cpptoc/post_data_cpptoc.h create mode 100644 libcef_dll/cpptoc/post_data_element_cpptoc.cc create mode 100644 libcef_dll/cpptoc/post_data_element_cpptoc.h delete mode 100644 libcef_dll/cpptoc/stream_cpptoc.cc create mode 100644 libcef_dll/cpptoc/stream_reader_cpptoc.cc rename libcef_dll/cpptoc/{stream_cpptoc.h => stream_reader_cpptoc.h} (54%) create mode 100644 libcef_dll/cpptoc/stream_writer_cpptoc.cc create mode 100644 libcef_dll/cpptoc/stream_writer_cpptoc.h create mode 100644 libcef_dll/ctocpp/base_ctocpp.h create mode 100644 libcef_dll/ctocpp/post_data_ctocpp.cc create mode 100644 libcef_dll/ctocpp/post_data_ctocpp.h create mode 100644 libcef_dll/ctocpp/post_data_element_ctocpp.cc create mode 100644 libcef_dll/ctocpp/post_data_element_ctocpp.h delete mode 100644 libcef_dll/ctocpp/stream_ctocpp.h create mode 100644 libcef_dll/ctocpp/stream_reader_ctocpp.cc create mode 100644 libcef_dll/ctocpp/stream_reader_ctocpp.h rename libcef_dll/ctocpp/{stream_ctocpp.cc => stream_writer_ctocpp.cc} (53%) create mode 100644 libcef_dll/ctocpp/stream_writer_ctocpp.h create mode 100644 tools/cef_parser.py create mode 100644 tools/make_capi_header.py create mode 100644 tools/make_cpptoc_header.py create mode 100644 tools/make_cpptoc_impl.py create mode 100644 tools/make_ctocpp_header.py create mode 100644 tools/make_ctocpp_impl.py create mode 100644 tools/translator.README.txt create mode 100644 tools/translator.bat create mode 100644 tools/translator.py diff --git a/include/cef.h b/include/cef.h index 9b90d37a0..870e3e0bf 100644 --- a/include/cef.h +++ b/include/cef.h @@ -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 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 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 CreateBrowserSync(CefWindowInfo& windowInfo, bool popup, CefRefPtr 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 GetHandler() =0; // Returns the main (top-level) frame for the browser window. + /*--cef()--*/ virtual CefRefPtr GetMainFrame() =0; // Returns the focused frame for the browser window. + /*--cef()--*/ virtual CefRefPtr GetFocusedFrame() =0; // Returns the frame with the specified name, or NULL if not found. + /*--cef()--*/ virtual CefRefPtr GetFrame(const std::wstring& name) =0; // Returns the names of all existing frames. + /*--cef()--*/ virtual void GetFrameNames(std::vector& 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 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 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 parentBrowser, CefWindowInfo& windowInfo, bool popup, CefRefPtr& 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 browser) =0; // Event called when a frame's address has changed. The return value is // currently ignored. + /*--cef()--*/ virtual RetVal HandleAddressChange(CefRefPtr browser, CefRefPtr frame, const std::wstring& url) =0; // Event called when the page title changes. The return value is currently // ignored. + /*--cef()--*/ virtual RetVal HandleTitleChange(CefRefPtr 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 browser, CefRefPtr frame, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr 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 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 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 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 browser, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr 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 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 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 browser, CefRefPtr frame, CefRefPtr 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 browser, bool isWidget) =0; }; // Class used to represent a web request. +/*--cef(source=library)--*/ class CefRequest : public CefBase { public: - typedef std::map HeaderMap; + typedef std::map HeaderMap; // Create a new CefRequest object. + /*--cef()--*/ static CefRefPtr 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 GetPostData() =0; + /*--cef()--*/ virtual void SetPostData(CefRefPtr 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 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 > ElementVector; + typedef std::vector> ElementVector; // Create a new CefPostData object. + /*--cef()--*/ static CefRefPtr 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 element) =0; // Add the specified post data element. Returns true if the add succeeds. + /*--cef()--*/ virtual bool AddElement(CefRefPtr 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 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 CreateForFile(const std::wstring& fileName); + /*--cef()--*/ static CefRefPtr 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> 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 object, - CefV8ValueList& arguments, + const CefV8ValueList& arguments, CefRefPtr& 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 CreateUndefined(); + /*--cef()--*/ static CefRefPtr CreateNull(); + /*--cef()--*/ static CefRefPtr CreateBool(bool value); + /*--cef()--*/ static CefRefPtr CreateInt(int value); + /*--cef()--*/ static CefRefPtr CreateDouble(double value); + /*--cef()--*/ static CefRefPtr CreateString(const std::wstring& value); + /*--cef()--*/ static CefRefPtr CreateObject(CefRefPtr user_data); + /*--cef()--*/ static CefRefPtr CreateArray(); + /*--cef()--*/ static CefRefPtr CreateFunction(const std::wstring& name, CefRefPtr 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 GetValue(const std::wstring& key) =0; + /*--cef(capi_name=get_value_byindex)--*/ virtual CefRefPtr GetValue(int index) =0; // Associate value with the specified identifier. + /*--cef(capi_name=set_value_bykey)--*/ virtual bool SetValue(const std::wstring& key, CefRefPtr value) =0; + /*--cef(capi_name=set_value_byindex)--*/ virtual bool SetValue(int index, CefRefPtr 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& keys) =0; // Returns the user data, if any, specified when the object was created. + /*--cef()--*/ virtual CefRefPtr 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 GetFunctionHandler() =0; // Execute the function. + /*--cef()--*/ virtual bool ExecuteFunction(CefRefPtr object, - CefV8ValueList& arguments, + const CefV8ValueList& arguments, CefRefPtr& retval, std::wstring& exception) =0; }; diff --git a/include/cef_capi.h b/include/cef_capi.h index 1c7aaa57d..585ca950a 100644 --- a/include/cef_capi.h +++ b/include/cef_capi.h @@ -1,32 +1,38 @@ -// 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. - +// 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 @@ -36,36 +42,34 @@ 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" - - -// 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 -// |multi_threaded_message_loop| to true to have the message loop run in -// a separate thread. If |multi_threaded_message_loop| is false than -// 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 NULL or empty an in-memory cache will be used for cache -// data. -CEF_EXPORT int cef_initialize(int multi_threaded_message_loop, - const wchar_t* cache_path); +#include "cef_string.h" +#include "cef_string_list.h" +#include "cef_string_map.h" +#include "cef_types.h" -// 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. + +// 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 (1) +// indicates that it succeeded and false (0) indicates that it failed. Set +// |multi_threaded_message_loop| to true (1) to have the message loop run in a +// separate thread. If |multi_threaded_message_loop| is false (0) than the +// cef_do_message_loop_work() 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 NULL an in-memory cache will be used for cache data. +CEF_EXPORT int cef_initialize(int multi_threaded_message_loop, + const wchar_t* 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_EXPORT void cef_shutdown(); // Perform message loop processing. Has no affect if the browser UI loop is // running in a separate thread. -CEF_EXPORT void cef_do_message_loop_work(); - +CEF_EXPORT void cef_do_message_loop_work(); + // 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: @@ -120,244 +124,268 @@ CEF_EXPORT void cef_do_message_loop_work(); // example.test.increment(); // CEF_EXPORT int cef_register_extension(const wchar_t* extension_name, - const wchar_t* javascript_code, - struct _cef_v8handler_t* handler); - - -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* base); - // Decrement the reference count. Delete this object when no references - // remain. - int (CEF_CALLBACK *release)(struct _cef_base_t* base); - // Returns the current number of references. - int (CEF_CALLBACK *get_refct)(struct _cef_base_t* base); -} 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)) - - + const wchar_t* javascript_code, struct _cef_v8handler_t* handler); + +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)) + + // Structure used to represent a browser window. All functions exposed by this -// structure should be thread safe. -typedef struct _cef_browser_t -{ - // Base structure - cef_base_t base; - +// structure should be thread safe. +typedef struct _cef_browser_t +{ + // Base structure. + cef_base_t base; + // Returns true (1) if the browser can navigate backwards. - int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* browser); + int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* self); + // Navigate backwards. - void (CEF_CALLBACK *go_back)(struct _cef_browser_t* browser); + void (CEF_CALLBACK *go_back)(struct _cef_browser_t* self); + // Returns true (1) if the browser can navigate forwards. - int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* browser); + int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* self); + // Navigate backwards. - void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* browser); + void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* self); + // Reload the current page. - void (CEF_CALLBACK *reload)(struct _cef_browser_t* browser); + void (CEF_CALLBACK *reload)(struct _cef_browser_t* self); + // Stop loading the page. - void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* browser); + void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self); // Set focus for the browser window. If |enable| is true (1) focus will be // set to the window. Otherwise, focus will be removed. - void (CEF_CALLBACK *set_focus)(struct _cef_browser_t* browser, int enable); + void (CEF_CALLBACK *set_focus)(struct _cef_browser_t* self, int enable); // Retrieve the window handle for this browser. cef_window_handle_t (CEF_CALLBACK *get_window_handle)( - struct _cef_browser_t* browser); + struct _cef_browser_t* self); // Returns true (1) if the window is a popup window. - int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* browser); + int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* self); // Returns the handler for this browser. struct _cef_handler_t* (CEF_CALLBACK *get_handler)( - struct _cef_browser_t* browser); - + struct _cef_browser_t* self); + // Returns the main (top-level) frame for the browser window. struct _cef_frame_t* (CEF_CALLBACK *get_main_frame)( - struct _cef_browser_t* browser); + struct _cef_browser_t* self); // Returns the focused frame for the browser window. struct _cef_frame_t* (CEF_CALLBACK *get_focused_frame)( - struct _cef_browser_t* browser); + struct _cef_browser_t* self); // Returns the frame with the specified name, or NULL if not found. - struct _cef_frame_t* (CEF_CALLBACK *get_frame)( - struct _cef_browser_t* browser, - const wchar_t* name); - - // Reads the names of all existing frames into the provided string list. - size_t (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* browser, - cef_string_list_t list); -} cef_browser_t; - - + struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self, + const wchar_t* name); + + // Returns the names of all existing frames. + void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self, + cef_string_list_t names); + +} cef_browser_t; + + +// Create a new browser window using the window parameters specified by +// |windowInfo|. All values will be copied internally and the actual window will +// be created on the UI thread. The |popup| parameter should be true (1) if the +// new window is a popup window. This function call will not block. +CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup, + struct _cef_handler_t* handler, const wchar_t* url); + +// Create a new browser window using the window parameters specified by +// |windowInfo|. The |popup| parameter should be true (1) if the new window is a +// popup window. This function call will block and can only be used if the +// |multi_threaded_message_loop| parameter to cef_initialize() is false (0). +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); + + // Structure used to represent a frame in the browser window. All functions -// exposed by this structure should be thread safe. -typedef struct _cef_frame_t -{ - // Base structure - cef_base_t base; - +// exposed by this structure should be thread safe. +typedef struct _cef_frame_t +{ + // Base structure. + cef_base_t base; + // Execute undo in this frame. - void (CEF_CALLBACK *undo)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *undo)(struct _cef_frame_t* self); + // Execute redo in this frame. - void (CEF_CALLBACK *redo)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *redo)(struct _cef_frame_t* self); + // Execute cut in this frame. - void (CEF_CALLBACK *cut)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *cut)(struct _cef_frame_t* self); + // Execute copy in this frame. - void (CEF_CALLBACK *copy)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *copy)(struct _cef_frame_t* self); + // Execute paste in this frame. - void (CEF_CALLBACK *paste)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *paste)(struct _cef_frame_t* self); + // Execute delete in this frame. - void (CEF_CALLBACK *del)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *del)(struct _cef_frame_t* self); + // Execute select all in this frame. - void (CEF_CALLBACK *select_all)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *select_all)(struct _cef_frame_t* self); // Execute printing in the this frame. The user will be prompted with the // print dialog appropriate to the operating system. - void (CEF_CALLBACK *print)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *print)(struct _cef_frame_t* self); // Save this frame's HTML source to a temporary file and open it in the // default text viewing application. - void (CEF_CALLBACK *view_source)(struct _cef_frame_t* frame); + void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self); - // Returns this frame's HTML source as a string. The returned string must be - // released using cef_string_free(). - cef_string_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* frame); + // Returns this frame's HTML source as a string. + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self); - // Returns this frame's display text as a string. The returned string must be - // released using cef_string_free(). - cef_string_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* frame); + // Returns this frame's display text as a string. + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self); // Load the request represented by the |request| object. - void (CEF_CALLBACK *load_request)(struct _cef_frame_t* frame, + void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self, struct _cef_request_t* request); // Load the specified |url|. - void (CEF_CALLBACK *load_url)(struct _cef_frame_t* frame, - const wchar_t* url); + void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self, const wchar_t* url); // Load the contents of |string| with the optional dummy target |url|. - void (CEF_CALLBACK *load_string)(struct _cef_frame_t* frame, + void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self, const wchar_t* string, const wchar_t* url); // Load the contents of |stream| with the optional dummy target |url|. - void (CEF_CALLBACK *load_stream)(struct _cef_frame_t* frame, + void (CEF_CALLBACK *load_stream)(struct _cef_frame_t* self, struct _cef_stream_reader_t* stream, const wchar_t* url); - // 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 + // 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. - void (CEF_CALLBACK *execute_javascript)(struct _cef_frame_t* frame, + void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self, const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine); // Returns true (1) if this is the main frame. - int (CEF_CALLBACK *is_main)(struct _cef_frame_t* frame); + int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self); // Returns true (1) if this is the focused frame. - int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* frame); + int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self); - // Returns this frame's name. The returned string must be released using - // cef_string_free(). - cef_string_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* frame); - - // Returns the currently loaded URL. The returned string must be released - // using cef_string_free(). - cef_string_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* frame); - -} cef_frame_t; + // Returns this frame's name. + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self); + + // Return the URL currently loaded in this frame. + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self); + +} cef_frame_t; -// Structure used to handle events generated by the browser window. All methods -// functions by this class should be thread safe. -typedef struct _cef_handler_t -{ - // Base structure - cef_base_t base; - +// Structure that should be implemented to handle events generated by the +// browser window. All functions exposed by this structure should be thread +// safe. Each function in the structure returns a RetVal value. +typedef struct _cef_handler_t +{ + // Base structure. + cef_base_t base; + // Event called before a new window is created. The |parentBrowser| parameter - // will point to the parent browser window, if any. The |popup| parameter - // will be true (1) if the new window is a popup window. If you create the - // window yourself you should populate the window handle member of - // |createInfo| and return RV_HANDLED. Otherwise, return RV_CONTINUE and the - // framework will 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. + // will point to the parent browser window, if any. The |popup| parameter will + // be true (1) if the new window is a popup window. If you create the window + // yourself you should populate the window handle member of |createInfo| and + // return RV_HANDLED. Otherwise, return RV_CONTINUE and the framework will + // 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. enum cef_retval_t (CEF_CALLBACK *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); - + struct _cef_handler_t* self, struct _cef_browser_t* parentBrowser, + struct _cef_window_info_t* windowInfo, int popup, + struct _cef_handler_t** handler, cef_string_t* url); + // Event called after a new window is created. The return value is currently // ignored. enum cef_retval_t (CEF_CALLBACK *handle_after_created)( - struct _cef_handler_t* handler, cef_browser_t* browser); + struct _cef_handler_t* self, struct _cef_browser_t* browser); - // Event called when the address bar changes. The return value is currently - // ignored. + // Event called when a frame's address has changed. The return value is + // currently ignored. enum cef_retval_t (CEF_CALLBACK *handle_address_change)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame, const wchar_t* url); + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, const wchar_t* url); // Event called when the page title changes. The return value is currently // ignored. enum cef_retval_t (CEF_CALLBACK *handle_title_change)( - struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_handler_t* self, struct _cef_browser_t* browser, const wchar_t* title); // Event called before browser navigation. The client has an opportunity to // modify the |request| object if desired. Return RV_HANDLED to cancel // navigation. enum cef_retval_t (CEF_CALLBACK *handle_before_browse)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame, struct _cef_request_t* request, + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_request_t* request, cef_handler_navtype_t navType, int isRedirect); // Event called when the browser begins loading a page. The |frame| pointer // will be NULL if the event represents the overall load status and not the - // load status for a particular frame. The return value is currently ignored. + // load status for a particular frame. The return value is currently ignored. enum cef_retval_t (CEF_CALLBACK *handle_load_start)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame); + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame); - // Event called when the browser is done loading a page. The |frame| pointer + // Event called when the browser is done loading a page. The |frame| pointer // will be NULL if the event represents the overall load status and not the // load status for a particular frame. This event will be generated // irrespective of whether the request completes successfully. The return // value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_load_end)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame); + enum cef_retval_t (CEF_CALLBACK *handle_load_end)(struct _cef_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame); - // Called when the browser fails to load a resource. |errorCode is the - // 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. + // Called when the browser fails to load a resource. |errorCode| is the 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. enum cef_retval_t (CEF_CALLBACK *handle_load_error)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame, cef_handler_errorcode_t errorCode, + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, cef_handler_errorcode_t errorCode, const wchar_t* failedUrl, cef_string_t* errorText); // Event called before a resource is loaded. To allow the resource to load - // 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. - // To cancel loading of the resource return RV_HANDLED. + // 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. To cancel loading + // of the resource return RV_HANDLED. enum cef_retval_t (CEF_CALLBACK *handle_before_resource_load)( - struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_handler_t* self, struct _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); @@ -365,400 +393,380 @@ typedef struct _cef_handler_t // Event called before a context menu is displayed. To cancel display of the // default context menu return RV_HANDLED. enum cef_retval_t (CEF_CALLBACK *handle_before_menu)( - struct _cef_handler_t* handler, cef_browser_t* browser, - const cef_handler_menuinfo_t* menuInfo); + struct _cef_handler_t* self, struct _cef_browser_t* browser, + const struct _cef_handler_menuinfo_t* menuInfo); // 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. enum cef_retval_t (CEF_CALLBACK *handle_get_menu_label)( - struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_handler_t* self, struct _cef_browser_t* browser, cef_handler_menuid_t menuId, cef_string_t* label); // Event called when an option is selected from the default context menu. // Return RV_HANDLED to cancel default handling of the action. enum cef_retval_t (CEF_CALLBACK *handle_menu_action)( - struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_handler_t* self, struct _cef_browser_t* browser, cef_handler_menuid_t menuId); // Event called to format print headers and footers. |printInfo| contains - // platform-specific information about the printer context. |url| is the - // URL if the currently printing page, |title| is the title of the currently + // platform-specific information about the printer context. |url| is the URL + // if the currently printing page, |title| is the title of the currently // printing page, |currentPage| is the current page number and |maxPages| is - // the total number of pages. Six default header locations are provided - // by the implementation: top left, top center, top right, bottom left, - // bottom center and bottom right. To use one of these default locations - // 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. + // the total number of pages. Six default header locations are provided by + // the implementation: top left, top center, top right, bottom left, bottom + // center and bottom right. To use one of these default locations 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. enum cef_retval_t (CEF_CALLBACK *handle_print_header_footer)( - struct _cef_handler_t* handler, 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, + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _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); - // Run a JS alert message. Return RV_CONTINUE to display the default alert - // or RV_HANDLED if you displayed a custom alert. - enum cef_retval_t (CEF_CALLBACK *handle_jsalert)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame, const wchar_t* message); - + // Run a JS alert message. Return RV_CONTINUE to display the default alert or + // RV_HANDLED if you displayed a custom alert. + enum cef_retval_t (CEF_CALLBACK *handle_jsalert)(struct _cef_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const wchar_t* message); + // 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 (1) if the user accepted the confirmation. enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame, const wchar_t* message, int* retval); - + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, const wchar_t* message, int* retval); + // 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 + // set |retval| to true (1) if the user accepted the prompt and request and // |result| to the resulting value. - enum cef_retval_t (CEF_CALLBACK *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); - + enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)(struct _cef_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const wchar_t* message, const wchar_t* defaultValue, int* retval, + cef_string_t* result); + // Called just before a window is closed. The return value is currently // ignored. enum cef_retval_t (CEF_CALLBACK *handle_before_window_close)( - struct _cef_handler_t* handler, cef_browser_t* browser); + struct _cef_handler_t* self, struct _cef_browser_t* browser); - // 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. + // 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. enum cef_retval_t (CEF_CALLBACK *handle_take_focus)( - struct _cef_handler_t* handler, cef_browser_t* browser, int reverse); + struct _cef_handler_t* self, struct _cef_browser_t* browser, + int reverse); - // 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. enum cef_retval_t (CEF_CALLBACK *handle_jsbinding)( - struct _cef_handler_t* handler, cef_browser_t* browser, - cef_frame_t* frame, struct _cef_v8value_t* object); + struct _cef_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_v8value_t* object); // Called when the browser component is requesting focus. |isWidget| will be // true (1) 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. enum cef_retval_t (CEF_CALLBACK *handle_set_focus)( - struct _cef_handler_t* handler, cef_browser_t* browser, int isWidget); + struct _cef_handler_t* self, struct _cef_browser_t* browser, + int isWidget); } cef_handler_t; // Structure used to represent a web request. -typedef struct _cef_request_t -{ - // Base structure - cef_base_t base; - - // Fully qualified URL to load. - cef_string_t (CEF_CALLBACK *get_url)(struct _cef_request_t* request); - void (CEF_CALLBACK *set_url)(struct _cef_request_t* request, - const wchar_t* url); +typedef struct _cef_request_t +{ + // Base structure. + cef_base_t base; - // Optional request method type, defaulting to POST if post data is provided + // Fully qualified URL to load. + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self); + void (CEF_CALLBACK *set_url)(struct _cef_request_t* self, const wchar_t* url); + + // Optional request function type, defaulting to POST if post data is provided // and GET otherwise. - cef_string_t (CEF_CALLBACK *get_method)(struct _cef_request_t* request); - void (CEF_CALLBACK *set_method)(struct _cef_request_t* request, + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self); + void (CEF_CALLBACK *set_method)(struct _cef_request_t* self, const wchar_t* method); // Optional post data. struct _cef_post_data_t* (CEF_CALLBACK *get_post_data)( - struct _cef_request_t* request); - void (CEF_CALLBACK *set_post_data)(struct _cef_request_t* request, + struct _cef_request_t* self); + void (CEF_CALLBACK *set_post_data)(struct _cef_request_t* self, struct _cef_post_data_t* postData); // Optional header values. - void (CEF_CALLBACK *get_header_map)(struct _cef_request_t* request, + void (CEF_CALLBACK *get_header_map)(struct _cef_request_t* self, cef_string_map_t headerMap); - void (CEF_CALLBACK *set_header_map)(struct _cef_request_t* request, + void (CEF_CALLBACK *set_header_map)(struct _cef_request_t* self, cef_string_map_t headerMap); // Set all values at one time. - void (CEF_CALLBACK *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 *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); + } cef_request_t; -// Structure used to represent post data for a web request. -typedef struct _cef_post_data_t -{ - // Base structure - cef_base_t base; - - // Returns the number of existing post data elements. - size_t (CEF_CALLBACK *get_element_count)(struct _cef_post_data_t* postData); +// Create a new cef_request_t object. +CEF_EXPORT cef_request_t* cef_request_create(); - // Retrieve the post data element at the specified zero-based index. - struct _cef_post_data_element_t* (CEF_CALLBACK *get_element)( - struct _cef_post_data_t* postData, int index); + +// Structure used to represent post data for a web request. +typedef struct _cef_post_data_t +{ + // Base structure. + cef_base_t base; + + // Returns the number of existing post data elements. + size_t (CEF_CALLBACK *get_element_count)(struct _cef_post_data_t* self); + + // Retrieve the post data elements. + struct _cef_post_data_element_t* (CEF_CALLBACK *get_elements)( + struct _cef_post_data_t* self, int elementIndex); // Remove the specified post data element. Returns true (1) if the removal // succeeds. - int (CEF_CALLBACK *remove_element)(struct _cef_post_data_t* postData, + int (CEF_CALLBACK *remove_element)(struct _cef_post_data_t* self, struct _cef_post_data_element_t* element); // Add the specified post data element. Returns true (1) if the add succeeds. - int (CEF_CALLBACK *add_element)(struct _cef_post_data_t* postData, + int (CEF_CALLBACK *add_element)(struct _cef_post_data_t* self, struct _cef_post_data_element_t* element); // Remove all existing post data elements. - void (CEF_CALLBACK *remove_elements)(struct _cef_post_data_t* postData); - + void (CEF_CALLBACK *remove_elements)(struct _cef_post_data_t* self); + } cef_post_data_t; +// Create a new cef_post_data_t object. +CEF_EXPORT cef_post_data_t* cef_post_data_create(); + + // Structure used to represent a single element in the request post data. -typedef struct _cef_post_data_element_t -{ - // Base structure - cef_base_t base; - +typedef struct _cef_post_data_element_t +{ + // Base structure. + cef_base_t base; + // Remove all contents from the post data element. - void (CEF_CALLBACK *set_to_empty)( - struct _cef_post_data_element_t* postDataElement); + void (CEF_CALLBACK *set_to_empty)(struct _cef_post_data_element_t* self); // The post data element will represent a file. - void (CEF_CALLBACK *set_to_file)( - struct _cef_post_data_element_t* postDataElement, + void (CEF_CALLBACK *set_to_file)(struct _cef_post_data_element_t* self, const wchar_t* fileName); - // The post data element will represent bytes. The bytes passed - // in will be copied. - void (CEF_CALLBACK *set_to_bytes)( - struct _cef_post_data_element_t* postDataElement, size_t size, - const void* bytes); + // The post data element will represent bytes. The bytes passed in will be + // copied. + void (CEF_CALLBACK *set_to_bytes)(struct _cef_post_data_element_t* self, + size_t size, const void* bytes); // Return the type of this post data element. - cef_postdataelement_type_t (CEF_CALLBACK *get_type)( - struct _cef_post_data_element_t* postDataElement); + enum cef_postdataelement_type_t (CEF_CALLBACK *get_type)( + struct _cef_post_data_element_t* self); // Return the file name. - cef_string_t (CEF_CALLBACK *get_file)( - struct _cef_post_data_element_t* postDataElement); + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_file)(struct _cef_post_data_element_t* self); // Return the number of bytes. - size_t (CEF_CALLBACK *get_bytes_count)( - struct _cef_post_data_element_t* postDataElement); + size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self); // Read up to |size| bytes into |bytes| and return the number of bytes // actually read. - size_t (CEF_CALLBACK *get_bytes)( - struct _cef_post_data_element_t* postDataElement, size_t size, - void *bytes); - + size_t (CEF_CALLBACK *get_bytes)(struct _cef_post_data_element_t* self, + size_t size, void *bytes); + } cef_post_data_element_t; +// Create a new cef_post_data_tElement object. +CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create(); + + // Structure used to read data from a stream. -typedef struct _cef_stream_reader_t -{ - // Base structure - cef_base_t base; - +typedef struct _cef_stream_reader_t +{ + // Base structure. + cef_base_t base; + // Read raw binary data. - size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* stream, void *ptr, + size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* self, void *ptr, size_t size, size_t n); - - // Seek to the specified offset position. |whence| may be any one of - // SEEK_CUR, SEEK_END or SEEK_SET. - int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* stream, long offset, + + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. + int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* self, long offset, int whence); - + // Return the current offset position. - long (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* stream); + long (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* self); // Return non-zero if at end of file. - int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* stream); - + int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* self); + } cef_stream_reader_t; +// Create a new cef_stream_reader_t object. +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( + const wchar_t* fileName); +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void *data, + size_t size); + + // Structure used to write data to a stream. -typedef struct _cef_stream_writer_t -{ - // Base structure - cef_base_t base; - - size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* stream, +typedef struct _cef_stream_writer_t +{ + // Base structure. + cef_base_t base; + + // Write raw binary data. + size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* self, const void *ptr, size_t size, size_t n); - - // Seek to the specified offset position. |whence| may be any one of - // SEEK_CUR, SEEK_END or SEEK_SET. - int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* stream, long offset, + + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. + int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* self, long offset, int whence); - + // Return the current offset position. - long (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* stream); + long (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* self); // Flush the stream. - int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* stream); - + int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* self); + } cef_stream_writer_t; // Structure that should be implemented to handle V8 function calls. -typedef struct _cef_v8handler_t -{ - // Base structure - cef_base_t base; - - // Execute a method with the specified argument vector and return - // value. Return true if the method was handled. - int (CEF_CALLBACK *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); - +typedef struct _cef_v8handler_t +{ + // Base structure. + cef_base_t base; + + // Execute with the specified argument list and return value. Return true (1) + // if the function was handled. + int (CEF_CALLBACK *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); + } cef_v8handler_t; // Structure representing a V8 value. -typedef struct _cef_v8value_t -{ - // Base structure - cef_base_t base; - +typedef struct _cef_v8value_t +{ + // Base structure. + cef_base_t base; + // Check the value type. - int (CEF_CALLBACK *is_undefined)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_null)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *is_function)(struct _cef_v8value_t* v8value); - + int (CEF_CALLBACK *is_undefined)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_null)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *is_function)(struct _cef_v8value_t* self); + // Return a primitive value type. The underlying data will be converted to // the requested type if necessary. - int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* v8value); - int (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* v8value); - double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* v8value); - // The returned string must be released using cef_string_free(). - cef_string_t (CEF_CALLBACK *get_string_value)(struct _cef_v8value_t* v8value); + int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self); + int (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self); + double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self); + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_string_value)(struct _cef_v8value_t* self); - // OBJECT METHODS - These methods are only available on objects. Arrays and + // OBJECT METHODS - These functions are only available on objects. Arrays and // functions are also objects. String- and integer-based keys can be used // interchangably with the framework converting between them as necessary. // Keys beginning with "Cef::" and "v8::" are reserved by the system. - // Returns true if the object has a value with the specified identifier. - int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* v8value, + // Returns true (1) if the object has a value with the specified identifier. + int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self, const wchar_t* key); - int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* v8value, - int index); - + int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index); + // Delete the value with the specified identifier. - int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* v8value, + int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self, const wchar_t* key); - int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* v8value, + int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self, int index); - + // Returns the value with the specified identifier. struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)( - struct _cef_v8value_t* v8value, - const wchar_t* key); + struct _cef_v8value_t* self, const wchar_t* key); struct _cef_v8value_t* (CEF_CALLBACK *get_value_byindex)( - struct _cef_v8value_t* v8value, - int index); - + struct _cef_v8value_t* self, int index); + // Associate value with the specified identifier. - int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* v8value, - const wchar_t* key, struct _cef_v8value_t* new_value); - int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* v8value, - int index, struct _cef_v8value_t* new_value); - + int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self, + const wchar_t* key, struct _cef_v8value_t* value); + int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index, + struct _cef_v8value_t* value); + // Read the keys for the object's values into the specified vector. Integer- // based keys will also be returned as strings. - int (CEF_CALLBACK *get_keys)(struct _cef_v8value_t* v8value, - cef_string_list_t list); + int (CEF_CALLBACK *get_keys)(struct _cef_v8value_t* self, + cef_string_list_t keys); // Returns the user data, if any, specified when the object was created. struct _cef_base_t* (CEF_CALLBACK *get_user_data)( - struct _cef_v8value_t* v8value); + struct _cef_v8value_t* self); - // ARRAY METHODS - These methods are only available on arrays. + // ARRAY METHODS - These functions are only available on arrays. // Returns the number of elements in the array. - int (CEF_CALLBACK *get_array_length)(struct _cef_v8value_t* v8value); - + int (CEF_CALLBACK *get_array_length)(struct _cef_v8value_t* self); - // FUNCTION METHODS - These methods are only available on functions. - // Returns the function name. The returned string must be released using - // cef_string_free(). - cef_string_t (CEF_CALLBACK *get_function_name)( - struct _cef_v8value_t* v8value); + // FUNCTION METHODS - These functions are only available on functions. + + // Returns the function name. + // The resulting string must be freed by calling cef_string_free(). + cef_string_t (CEF_CALLBACK *get_function_name)(struct _cef_v8value_t* self); // Returns the function handler or NULL if not a CEF-created function. struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)( - struct _cef_v8value_t* v8value); + struct _cef_v8value_t* self); // Execute the function. - int (CEF_CALLBACK *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); - + int (CEF_CALLBACK *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); + } cef_v8value_t; -// Create a new browser window using the window parameters specified -// by |windowInfo|. All values will be copied internally and the actual -// window will be created on the UI thread. The |popup| parameter should -// be true (1) if the new window is a popup window. This method call will not -// block. -CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup, - cef_handler_t* handler, const wchar_t* url); - -// Create a new browser window using the window parameters specified -// by |windowInfo|. The |popup| parameter should be true (1) 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_EXPORT cef_browser_t* cef_create_browser_sync(cef_window_info_t* windowInfo, - int popup, - cef_handler_t* handler, - const wchar_t* url); - -// Create a new request structure. -CEF_EXPORT cef_request_t* cef_create_request(); - -// Create a new post data structure. -CEF_EXPORT cef_post_data_t* cef_create_post_data(); - -// Create a new post data element structure. -CEF_EXPORT cef_post_data_element_t* cef_create_post_data_element(); - -// Create a new stream reader structure for reading from the specified file. -CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_file( - const wchar_t* fileName); - -// Create a new stream reader structure for reading from the specified data. -CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_data(void *data, - size_t size); - -// Create a new value 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_script_binding +// 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. -CEF_EXPORT cef_v8value_t* cef_create_v8value_undefined(); -CEF_EXPORT cef_v8value_t* cef_create_v8value_null(); -CEF_EXPORT cef_v8value_t* cef_create_v8value_bool(int value); -CEF_EXPORT cef_v8value_t* cef_create_v8value_int(int value); -CEF_EXPORT cef_v8value_t* cef_create_v8value_double(double value); -CEF_EXPORT cef_v8value_t* cef_create_v8value_string(const wchar_t* value); -CEF_EXPORT cef_v8value_t* cef_create_v8value_object(cef_base_t* user_data); -CEF_EXPORT cef_v8value_t* cef_create_v8value_array(); -CEF_EXPORT cef_v8value_t* cef_create_v8value_function(const wchar_t* name, - cef_v8handler_t* handler); +CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined(); +CEF_EXPORT cef_v8value_t* cef_v8value_create_null(); +CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value); +CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value); +CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value); +CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value); +CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data); +CEF_EXPORT cef_v8value_t* cef_v8value_create_array(); +CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name, + cef_v8handler_t* handler); #ifdef __cplusplus diff --git a/libcef/v8_impl.cc b/libcef/v8_impl.cc index 10224a6ef..451df5544 100644 --- a/libcef/v8_impl.cc +++ b/libcef/v8_impl.cc @@ -649,9 +649,9 @@ CefRefPtr CefV8ValueImpl::GetFunctionHandler() } bool CefV8ValueImpl::ExecuteFunction(CefRefPtr object, - CefV8ValueList& arguments, - CefRefPtr& retval, - std::wstring& exception) + const CefV8ValueList& arguments, + CefRefPtr& retval, + std::wstring& exception) { bool rv = false; Lock(); diff --git a/libcef/v8_impl.h b/libcef/v8_impl.h index faf8f8205..9d7b4e550 100644 --- a/libcef/v8_impl.h +++ b/libcef/v8_impl.h @@ -49,7 +49,7 @@ public: virtual std::wstring GetFunctionName(); virtual CefRefPtr GetFunctionHandler(); virtual bool ExecuteFunction(CefRefPtr object, - CefV8ValueList& arguments, + const CefV8ValueList& arguments, CefRefPtr& retval, std::wstring& exception); diff --git a/libcef_dll/cpptoc/base_cpptoc.h b/libcef_dll/cpptoc/base_cpptoc.h new file mode 100644 index 000000000..e9773d24d --- /dev/null +++ b/libcef_dll/cpptoc/base_cpptoc.h @@ -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 +{ +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 Get(cef_base_t* s) + { + // Cast our structure to the wrapper structure type. + CefBaseCppToC::Struct* wrapperStruct = + reinterpret_cast(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 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 Unwrap(cef_base_t* s) + { + // Cast our structure to the wrapper structure type. + CefBaseCppToC::Struct* wrapperStruct = + reinterpret_cast(s); + // Add the underlying object instance to a smart pointer. + CefRefPtr 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::AddRef(); + } + virtual int Release() + { + UnderlyingRelease(); + return CefThreadSafeBase::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(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(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(base); + return impl->class_->GetRefCt(); + } + +protected: + Struct struct_; + CefBase* class_; +}; + +#endif // _BASE_CPPTOC_H diff --git a/libcef_dll/cpptoc/browser_cpptoc.cc b/libcef_dll/cpptoc/browser_cpptoc.cc index d893edce1..849c75d1a 100644 --- a/libcef_dll/cpptoc/browser_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_cpptoc.cc @@ -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 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 handlerPtr; + std::wstring urlStr; + CefWindowInfo wi = *windowInfo; + + if(handler) + handlerPtr = CefHandlerCToCpp::Wrap(handler); + if(url) + urlStr = url; + + CefRefPtr 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 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 browserPtr = CefBrowserCppToC::Get(self); CefRefPtr 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 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 browserPtr = CefBrowserCppToC::Get(self); CefRefPtr 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 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 browserPtr = CefBrowserCppToC::Get(self); CefRefPtr 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 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 browserPtr = CefBrowserCppToC::Get(self); CefRefPtr 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 browserPtr = CefBrowserCppToC::Get(browser); - std::vector 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(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 browserPtr = CefBrowserCppToC::Get(self); + std::vector 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(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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/cpptoc/browser_cpptoc.h b/libcef_dll/cpptoc/browser_cpptoc.h index 9c0244074..ce237abef 100644 --- a/libcef_dll/cpptoc/browser_cpptoc.h +++ b/libcef_dll/cpptoc/browser_cpptoc.h @@ -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 +{ +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 -{ -public: - CefBrowserCppToC(CefBrowser* cls); - virtual ~CefBrowserCppToC() {} -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _BROWSER_CPPTOC_H diff --git a/libcef_dll/cpptoc/cpptoc.h b/libcef_dll/cpptoc/cpptoc.h index 1ed1a24ef..8d012cb54 100644 --- a/libcef_dll/cpptoc/cpptoc.h +++ b/libcef_dll/cpptoc/cpptoc.h @@ -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 CefCppToC : public CefThreadSafeBase { -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 Get(StructName* s) - { - // Cast our structure to the wrapper structure type. - ClassName::Struct* wrapperStruct = - reinterpret_cast(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 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 Get(StructName* s) + { + // Cast our structure to the wrapper structure type. + ClassName::Struct* wrapperStruct = + reinterpret_cast(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 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 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 Unwrap(StructName* s) + { + // Cast our structure to the wrapper structure type. ClassName::Struct* wrapperStruct = - reinterpret_cast(s); - // Add the underlying object instance to a smart pointer. - CefRefPtr 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(s); + // Add the underlying object instance to a smart pointer. + CefRefPtr 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* 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::AddRef(); } - virtual int Release() - { + virtual int Release() + { UnderlyingRelease(); - return CefThreadSafeBase::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(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(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(base); - return impl->class_->GetRefCt(); - } - -protected: + return CefThreadSafeBase::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(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(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(base); + return impl->class_->GetRefCt(); + } + +protected: Struct struct_; - BaseName* class_; + BaseName* class_; }; -// CefCppToC implementation for CefBase. -class CefBaseCppToC : public CefThreadSafeBase -{ -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 Get(cef_base_t* s) - { - // Cast our structure to the wrapper structure type. - CefBaseCppToC::Struct* wrapperStruct = - reinterpret_cast(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 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 Unwrap(cef_base_t* s) - { - // Cast our structure to the wrapper structure type. - CefBaseCppToC::Struct* wrapperStruct = - reinterpret_cast(s); - // Add the underlying object instance to a smart pointer. - CefRefPtr 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::AddRef(); - } - virtual int Release() - { - UnderlyingRelease(); - return CefThreadSafeBase::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(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(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(base); - return impl->class_->GetRefCt(); - } - -protected: - Struct struct_; - CefBase* class_; -}; - -#endif // _CPPTOC_H +#endif // _CPPTOC_H diff --git a/libcef_dll/cpptoc/frame_cpptoc.cc b/libcef_dll/cpptoc/frame_cpptoc.cc index 4a4e28f54..1e0e9200b 100644 --- a/libcef_dll/cpptoc/frame_cpptoc.cc +++ b/libcef_dll/cpptoc/frame_cpptoc.cc @@ -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 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 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 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 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(cls) -{ + +// CONSTRUCTOR - Do not edit by hand. + +CefFrameCppToC::CefFrameCppToC(CefFrame* cls) + : CefCppToC(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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/cpptoc/frame_cpptoc.h b/libcef_dll/cpptoc/frame_cpptoc.h index 0a21acc7c..2e49b9f6a 100644 --- a/libcef_dll/cpptoc/frame_cpptoc.h +++ b/libcef_dll/cpptoc/frame_cpptoc.h @@ -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 +{ +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 -{ -public: - CefFrameCppToC(CefFrame* cls); - virtual ~CefFrameCppToC() {} -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _FRAME_CPPTOC_H diff --git a/libcef_dll/cpptoc/handler_cpptoc.cc b/libcef_dll/cpptoc/handler_cpptoc.cc index 5af421a07..38400a6a1 100644 --- a/libcef_dll/cpptoc/handler_cpptoc.cc +++ b/libcef_dll/cpptoc/handler_cpptoc.cc @@ -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 handlerPtr = CefHandlerCppToC::Unwrap(*newHandler); - CefHandler* origHandler = handlerPtr.get(); - - // |parentBrowser| will be NULL if this is a top-level browser window. - CefRefPtr 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 handlerPtr = CefHandlerCppToC::Unwrap(*handler); + CefHandler* origHandler = handlerPtr.get(); + + // |parentBrowser| will be NULL if this is a top-level browser window. + CefRefPtr 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 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 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 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 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 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 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(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(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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/cpptoc/handler_cpptoc.h b/libcef_dll/cpptoc/handler_cpptoc.h index 1632d057e..6b345d8fe 100644 --- a/libcef_dll/cpptoc/handler_cpptoc.h +++ b/libcef_dll/cpptoc/handler_cpptoc.h @@ -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 +{ +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 -{ -public: - CefHandlerCppToC(CefHandler* cls); - virtual ~CefHandlerCppToC() {} -}; - - -#endif // USING_CEF_SHARED -#endif // _HANDLER_CPPTOC_H diff --git a/libcef_dll/cpptoc/post_data_cpptoc.cc b/libcef_dll/cpptoc/post_data_cpptoc.cc new file mode 100644 index 000000000..1f51c6536 --- /dev/null +++ b/libcef_dll/cpptoc/post_data_cpptoc.cc @@ -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 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 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 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(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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/post_data_cpptoc.h b/libcef_dll/cpptoc/post_data_cpptoc.h new file mode 100644 index 000000000..df182fe6c --- /dev/null +++ b/libcef_dll/cpptoc/post_data_cpptoc.h @@ -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 +{ +public: + CefPostDataCppToC(CefPostData* cls); + virtual ~CefPostDataCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // _POSTDATA_CPPTOC_H + diff --git a/libcef_dll/cpptoc/post_data_element_cpptoc.cc b/libcef_dll/cpptoc/post_data_element_cpptoc.cc new file mode 100644 index 000000000..0a20f2c0a --- /dev/null +++ b/libcef_dll/cpptoc/post_data_element_cpptoc.cc @@ -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 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(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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/post_data_element_cpptoc.h b/libcef_dll/cpptoc/post_data_element_cpptoc.h new file mode 100644 index 000000000..c6732a6f1 --- /dev/null +++ b/libcef_dll/cpptoc/post_data_element_cpptoc.h @@ -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 +{ +public: + CefPostDataElementCppToC(CefPostDataElement* cls); + virtual ~CefPostDataElementCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // _POSTDATAELEMENT_CPPTOC_H + diff --git a/libcef_dll/cpptoc/request_cpptoc.cc b/libcef_dll/cpptoc/request_cpptoc.cc index 383cb638c..21050d2f3 100644 --- a/libcef_dll/cpptoc/request_cpptoc.cc +++ b/libcef_dll/cpptoc/request_cpptoc.cc @@ -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 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 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 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 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(cls) -{ +// CONSTRUCTOR - Do not edit by hand. + +CefRequestCppToC::CefRequestCppToC(CefRequest* cls) + : CefCppToC(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::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 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 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(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::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(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::DebugObjCt = 0; -#endif diff --git a/libcef_dll/cpptoc/request_cpptoc.h b/libcef_dll/cpptoc/request_cpptoc.h index c7b2fc2cf..3104a8542 100644 --- a/libcef_dll/cpptoc/request_cpptoc.h +++ b/libcef_dll/cpptoc/request_cpptoc.h @@ -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 +{ +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 -{ -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 -{ -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 -{ -public: - CefPostDataElementCppToC(CefPostDataElement* cls); - virtual ~CefPostDataElementCppToC() {} -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _REQUEST_CPPTOC_H diff --git a/libcef_dll/cpptoc/stream_cpptoc.cc b/libcef_dll/cpptoc/stream_cpptoc.cc deleted file mode 100644 index 6062e7b8c..000000000 --- a/libcef_dll/cpptoc/stream_cpptoc.cc +++ /dev/null @@ -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(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::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(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::DebugObjCt = 0; -#endif diff --git a/libcef_dll/cpptoc/stream_reader_cpptoc.cc b/libcef_dll/cpptoc/stream_reader_cpptoc.cc new file mode 100644 index 000000000..542757f07 --- /dev/null +++ b/libcef_dll/cpptoc/stream_reader_cpptoc.cc @@ -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 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 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( + 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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/stream_cpptoc.h b/libcef_dll/cpptoc/stream_reader_cpptoc.h similarity index 54% rename from libcef_dll/cpptoc/stream_cpptoc.h rename to libcef_dll/cpptoc/stream_reader_cpptoc.h index 5266faa52..a8e86be7a 100644 --- a/libcef_dll/cpptoc/stream_cpptoc.h +++ b/libcef_dll/cpptoc/stream_reader_cpptoc.h @@ -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 +{ +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 -{ -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 -{ -public: - CefStreamWriterCppToC(CefStreamWriter* cls); - virtual ~CefStreamWriterCppToC() {} -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _STREAM_CPPTOC_H diff --git a/libcef_dll/cpptoc/stream_writer_cpptoc.cc b/libcef_dll/cpptoc/stream_writer_cpptoc.cc new file mode 100644 index 000000000..700859ed1 --- /dev/null +++ b/libcef_dll/cpptoc/stream_writer_cpptoc.cc @@ -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( + 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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/stream_writer_cpptoc.h b/libcef_dll/cpptoc/stream_writer_cpptoc.h new file mode 100644 index 000000000..35b40b755 --- /dev/null +++ b/libcef_dll/cpptoc/stream_writer_cpptoc.h @@ -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 +{ +public: + CefStreamWriterCppToC(CefStreamWriter* cls); + virtual ~CefStreamWriterCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // _STREAMWRITER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/v8handler_cpptoc.cc b/libcef_dll/cpptoc/v8handler_cpptoc.cc index 17aeccd76..297c787d4 100644 --- a/libcef_dll/cpptoc/v8handler_cpptoc.cc +++ b/libcef_dll/cpptoc/v8handler_cpptoc.cc @@ -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 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 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 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(arguments[i]))); + } + + CefRefPtr 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(cls) -{ - struct_.struct_.execute = v8handler_execute; -} + +// CONSTRUCTOR - Do not edit by hand. + +CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls) + : CefCppToC(cls) +{ + struct_.struct_.execute = v8handler_execute; +} #ifdef _DEBUG -long CefCppToC::DebugObjCt - = 0; +long CefCppToC::DebugObjCt = + 0; #endif + diff --git a/libcef_dll/cpptoc/v8handler_cpptoc.h b/libcef_dll/cpptoc/v8handler_cpptoc.h index 33e3f23f3..1751c33d8 100644 --- a/libcef_dll/cpptoc/v8handler_cpptoc.h +++ b/libcef_dll/cpptoc/v8handler_cpptoc.h @@ -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 +{ +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 -{ -public: - CefV8HandlerCppToC(CefV8Handler* cls); - virtual ~CefV8HandlerCppToC() {} -}; - - -#endif // USING_CEF_SHARED -#endif // _V8HANDLER_CPPTOC_H diff --git a/libcef_dll/cpptoc/v8value_cpptoc.cc b/libcef_dll/cpptoc/v8value_cpptoc.cc index 4d9f3c4ee..6a9ebc5d3 100644 --- a/libcef_dll/cpptoc/v8value_cpptoc.cc +++ b/libcef_dll/cpptoc/v8value_cpptoc.cc @@ -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 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 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 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 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 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 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 basePtr; + if(user_data) + basePtr = CefBaseCToCpp::Wrap(user_data); + + CefRefPtr impl = CefV8Value::CreateObject(basePtr); + if(impl.get()) + return CefV8ValueCppToC::Wrap(impl); + return NULL; +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_array() +{ + CefRefPtr 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 handlerPtr; + if(handler) + handlerPtr = CefV8HandlerCToCpp::Wrap(handler); + + CefRefPtr 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 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 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 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 valuePtr = CefV8ValueCppToC::Unwrap(new_value); - return CefV8ValueCppToC::Get(v8value)->SetValue(keyStr, valuePtr); -} + CefRefPtr 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 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 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 base = CefV8ValueCppToC::Get(v8value)->GetUserData(); - if(base.get()) - return CefBaseCToCpp::Unwrap(base); - return NULL; -} + CefRefPtr 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 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 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 objectPtr = CefV8ValueCppToC::Unwrap(object); - CefV8ValueList argsList; - for(size_t i = 0; i < numargs; i++) - argsList.push_back(CefV8ValueCppToC::Unwrap(args[i])); - CefRefPtr 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 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(cls) -{ +cef_base_t* CEF_CALLBACK v8value_get_user_data(struct _cef_v8value_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + CefRefPtr 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 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 objectPtr = CefV8ValueCppToC::Unwrap(object); + CefV8ValueList argsList; + for(size_t i = 0; i < argumentCount; i++) { + argsList.push_back(CefV8ValueCppToC::Unwrap( + const_cast(arguments[i]))); + } + CefRefPtr 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(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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/cpptoc/v8value_cpptoc.h b/libcef_dll/cpptoc/v8value_cpptoc.h index 447dc581c..a561aeb39 100644 --- a/libcef_dll/cpptoc/v8value_cpptoc.h +++ b/libcef_dll/cpptoc/v8value_cpptoc.h @@ -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 +{ +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 -{ -public: - CefV8ValueCppToC(CefV8Value* cls); - virtual ~CefV8ValueCppToC() {} -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _V8VALUE_CPPTOC_H diff --git a/libcef_dll/ctocpp/base_ctocpp.h b/libcef_dll/ctocpp/base_ctocpp.h new file mode 100644 index 000000000..223359e33 --- /dev/null +++ b/libcef_dll/ctocpp/base_ctocpp.h @@ -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 +{ +public: + // Use this method to create a wrapper class instance for a structure + // received from the other side. + static CefRefPtr 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 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 c) + { + // Cast the object to our wrapper class type. + CefBaseCToCpp* wrapper = static_cast(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::AddRef(); + } + virtual int Release() + { + UnderlyingRelease(); + return CefThreadSafeBase::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 diff --git a/libcef_dll/ctocpp/browser_ctocpp.cc b/libcef_dll/ctocpp/browser_ctocpp.cc index 3b781c9a9..a2e297670 100644 --- a/libcef_dll/ctocpp/browser_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_ctocpp.cc @@ -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 handler, const std::wstring& url) +{ + return cef_browser_create(&windowInfo, popup, CefHandlerCppToC::Wrap(handler), + url.c_str()); +} + +CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, + bool popup, CefRefPtr 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& names) cef_string_list_free(list); } + #ifdef _DEBUG long CefCToCpp::DebugObjCt = 0; #endif + diff --git a/libcef_dll/ctocpp/browser_ctocpp.h b/libcef_dll/ctocpp/browser_ctocpp.h index 0deee70fa..9c35a5509 100644 --- a/libcef_dll/ctocpp/browser_ctocpp.h +++ b/libcef_dll/ctocpp/browser_ctocpp.h @@ -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 { -public: - CefBrowserCToCpp(cef_browser_t* str) - : CefCToCpp(str) {} - virtual ~CefBrowserCToCpp() {} - +public: + CefBrowserCToCpp(cef_browser_t* str) + : CefCToCpp(str) {} + virtual ~CefBrowserCToCpp() {} + // CefBrowser methods virtual bool CanGoBack(); virtual void GoBack(); @@ -38,9 +44,9 @@ public: virtual CefRefPtr GetMainFrame(); virtual CefRefPtr GetFocusedFrame(); virtual CefRefPtr GetFrame(const std::wstring& name); - virtual void GetFrameNames(std::vector& names); -}; - - -#endif // USING_CEF_SHARED -#endif // _BROWSER_CTOCPP_H + virtual void GetFrameNames(std::vector& names); +}; + +#endif // USING_CEF_SHARED +#endif // _BROWSER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/ctocpp.h b/libcef_dll/ctocpp/ctocpp.h index a38d03147..f2da70f66 100644 --- a/libcef_dll/ctocpp/ctocpp.h +++ b/libcef_dll/ctocpp/ctocpp.h @@ -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 CefCToCpp : public CefThreadSafeBase { -public: - // Use this method to create a wrapper class instance for a structure - // received from the other side. - static CefRefPtr 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 Wrap(StructName* s) + { + // Wrap their structure with the CefCToCpp object. ClassName* wrapper = new ClassName(s); // Put the wrapper object in a smart pointer. - CefRefPtr 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 c) - { - // Cast the object to our wrapper class type. - ClassName* wrapper = static_cast(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 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 c) + { + // Cast the object to our wrapper class type. + ClassName* wrapper = static_cast(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::AddRef(); } - virtual int Release() - { + virtual int Release() + { UnderlyingRelease(); - return CefThreadSafeBase::Release(); - } - - // Increment/decrement reference counts on only the underlying class. - int UnderlyingAddRef() - { + return CefThreadSafeBase::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 -{ -public: - // Use this method to create a wrapper class instance for a structure - // received from the other side. - static CefRefPtr 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 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 c) - { - // Cast the object to our wrapper class type. - CefBaseCToCpp* wrapper = static_cast(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::AddRef(); - } - virtual int Release() - { - UnderlyingRelease(); - return CefThreadSafeBase::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 diff --git a/libcef_dll/ctocpp/frame_ctocpp.cc b/libcef_dll/ctocpp/frame_ctocpp.cc index 5e58919d1..9d464b014 100644 --- a/libcef_dll/ctocpp/frame_ctocpp.cc +++ b/libcef_dll/ctocpp/frame_ctocpp.cc @@ -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 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 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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/ctocpp/frame_ctocpp.h b/libcef_dll/ctocpp/frame_ctocpp.h index 09fdbf782..fedd3cc18 100644 --- a/libcef_dll/ctocpp/frame_ctocpp.h +++ b/libcef_dll/ctocpp/frame_ctocpp.h @@ -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 +#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 { -public: - CefFrameCToCpp(cef_frame_t* str) - : CefCToCpp(str) {} - virtual ~CefFrameCToCpp() {} - +public: + CefFrameCToCpp(cef_frame_t* str) + : CefCToCpp(str) {} + virtual ~CefFrameCToCpp() {} + // CefFrame methods virtual void Undo(); virtual void Redo(); @@ -37,19 +44,17 @@ public: virtual std::wstring GetText(); virtual void LoadRequest(CefRefPtr 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 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 + diff --git a/libcef_dll/ctocpp/handler_ctocpp.cc b/libcef_dll/ctocpp/handler_ctocpp.cc index 11e7513a3..8fea526c7 100644 --- a/libcef_dll/ctocpp/handler_ctocpp.cc +++ b/libcef_dll/ctocpp/handler_ctocpp.cc @@ -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 parentBrowser, CefWindowInfo& windowInfo, bool popup, CefRefPtr& handler, std::wstring& url) @@ -122,7 +132,8 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd( CefHandler::RetVal CefHandlerCToCpp::HandleLoadError( CefRefPtr browser, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr 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 browser, CefRefPtr frame, - const std::wstring& message, const std::wstring& defaultValue, bool& retval, - std::wstring& result) + CefRefPtr browser, CefRefPtr 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 browser) -{ +CefHandler::RetVal CefHandlerCToCpp::HandleBeforeWindowClose( + CefRefPtr 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 browser, bool reverse) { @@ -317,7 +329,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus( reverse); } -CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding( +CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding( CefRefPtr browser, CefRefPtr frame, CefRefPtr object) { @@ -331,13 +343,15 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding( CefHandler::RetVal CefHandlerCToCpp::HandleSetFocus( CefRefPtr 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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/ctocpp/handler_ctocpp.h b/libcef_dll/ctocpp/handler_ctocpp.h index 234138a94..a8a34b559 100644 --- a/libcef_dll/ctocpp/handler_ctocpp.h +++ b/libcef_dll/ctocpp/handler_ctocpp.h @@ -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 { -public: - CefHandlerCToCpp(cef_handler_t* str) - : CefCToCpp(str) {} - virtual ~CefHandlerCToCpp() {} - +public: + CefHandlerCToCpp(cef_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefHandlerCToCpp() {} + // CefHandler methods virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& windowInfo, bool popup, - CefRefPtr& handler, - std::wstring& url); + CefWindowInfo& windowInfo, bool popup, CefRefPtr& handler, + std::wstring& url); virtual RetVal HandleAfterCreated(CefRefPtr browser); virtual RetVal HandleAddressChange(CefRefPtr browser, - CefRefPtr frame, - const std::wstring& url); + CefRefPtr frame, const std::wstring& url); virtual RetVal HandleTitleChange(CefRefPtr browser, - const std::wstring& title); + const std::wstring& title); virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - NavType navType, bool isRedirect); + CefRefPtr frame, CefRefPtr request, + NavType navType, bool isRedirect); virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame); + CefRefPtr frame); virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame); + CefRefPtr frame); virtual RetVal HandleLoadError(CefRefPtr browser, - CefRefPtr frame, - ErrorCode errorCode, - const std::wstring& failedUrl, - std::wstring& errorText); + CefRefPtr frame, ErrorCode errorCode, + const std::wstring& failedUrl, std::wstring& errorText); virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, - CefRefPtr request, - std::wstring& redirectUrl, - CefRefPtr& resourceStream, - std::wstring& mimeType, - int loadFlags); + CefRefPtr request, std::wstring& redirectUrl, + CefRefPtr& resourceStream, std::wstring& mimeType, + int loadFlags); virtual RetVal HandleBeforeMenu(CefRefPtr browser, - const MenuInfo& menuInfo); + const MenuInfo& menuInfo); virtual RetVal HandleGetMenuLabel(CefRefPtr browser, - MenuId menuId, std::wstring& label); - virtual RetVal HandleMenuAction(CefRefPtr browser, - MenuId menuId); + MenuId menuId, std::wstring& label); + virtual RetVal HandleMenuAction(CefRefPtr browser, MenuId menuId); virtual RetVal HandlePrintHeaderFooter(CefRefPtr browser, - CefRefPtr 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 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 browser, - CefRefPtr frame, - const std::wstring& message); + CefRefPtr frame, const std::wstring& message); virtual RetVal HandleJSConfirm(CefRefPtr browser, - CefRefPtr frame, - const std::wstring& message, bool& retval); + CefRefPtr frame, const std::wstring& message, bool& retval); virtual RetVal HandleJSPrompt(CefRefPtr browser, - CefRefPtr frame, - const std::wstring& message, - const std::wstring& default_value, - bool& retval, - std::wstring& result); - virtual RetVal HandleBeforeWindowClose(CefRefPtr browser); - virtual RetVal HandleTakeFocus(CefRefPtr browser, - bool reverse); - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr object); - virtual RetVal HandleSetFocus(CefRefPtr browser, - bool isWidget); -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _HANDLER_CTOCPP_H + CefRefPtr frame, const std::wstring& message, + const std::wstring& defaultValue, bool& retval, std::wstring& result); + virtual RetVal HandleBeforeWindowClose(CefRefPtr browser); + virtual RetVal HandleTakeFocus(CefRefPtr browser, bool reverse); + virtual RetVal HandleJSBinding(CefRefPtr browser, + CefRefPtr frame, CefRefPtr object); + virtual RetVal HandleSetFocus(CefRefPtr browser, bool isWidget); +}; + +#endif // BUILDING_CEF_SHARED +#endif // _HANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/post_data_ctocpp.cc b/libcef_dll/ctocpp/post_data_ctocpp.cc new file mode 100644 index 000000000..6fb5fa3ed --- /dev/null +++ b/libcef_dll/ctocpp/post_data_ctocpp.cc @@ -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::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 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 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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/post_data_ctocpp.h b/libcef_dll/ctocpp/post_data_ctocpp.h new file mode 100644 index 000000000..f514c6428 --- /dev/null +++ b/libcef_dll/ctocpp/post_data_ctocpp.h @@ -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 +{ +public: + CefPostDataCToCpp(cef_post_data_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataCToCpp() {} + + // CefPostData methods + virtual size_t GetElementCount(); + virtual void GetElements(ElementVector& elements); + virtual bool RemoveElement(CefRefPtr element); + virtual bool AddElement(CefRefPtr element); + virtual void RemoveElements(); +}; + +#endif // USING_CEF_SHARED +#endif // _POSTDATA_CTOCPP_H + diff --git a/libcef_dll/ctocpp/post_data_element_ctocpp.cc b/libcef_dll/ctocpp/post_data_element_ctocpp.cc new file mode 100644 index 000000000..9fb88e2d7 --- /dev/null +++ b/libcef_dll/ctocpp/post_data_element_ctocpp.cc @@ -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::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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/post_data_element_ctocpp.h b/libcef_dll/ctocpp/post_data_element_ctocpp.h new file mode 100644 index 000000000..3d5bd8cc7 --- /dev/null +++ b/libcef_dll/ctocpp/post_data_element_ctocpp.h @@ -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 +{ +public: + CefPostDataElementCToCpp(cef_post_data_element_t* str) + : CefCToCpp(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 + diff --git a/libcef_dll/ctocpp/request_ctocpp.cc b/libcef_dll/ctocpp/request_ctocpp.cc index 882da8841..8d25a866e 100644 --- a/libcef_dll/ctocpp/request_ctocpp.cc +++ b/libcef_dll/ctocpp/request_ctocpp.cc @@ -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::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 postData, - const HeaderMap& headerMap) +void CefRequestCToCpp::Set(const std::wstring& url, const std::wstring& method, + CefRefPtr 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::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 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 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::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::DebugObjCt = 0; -#endif diff --git a/libcef_dll/ctocpp/request_ctocpp.h b/libcef_dll/ctocpp/request_ctocpp.h index 50f2bb1c4..f2392762f 100644 --- a/libcef_dll/ctocpp/request_ctocpp.h +++ b/libcef_dll/ctocpp/request_ctocpp.h @@ -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 { -public: - CefRequestCToCpp(cef_request_t* str) - : CefCToCpp(str) {} - virtual ~CefRequestCToCpp() {} - - // CefRequest methods +public: + CefRequestCToCpp(cef_request_t* str) + : CefCToCpp(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 postData); virtual void GetHeaderMap(HeaderMap& headerMap); virtual void SetHeaderMap(const HeaderMap& headerMap); - virtual void Set(const std::wstring& url, - const std::wstring& method, - CefRefPtr 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 -{ -public: - CefPostDataCToCpp(cef_post_data_t* str) - : CefCToCpp(str) {} - virtual ~CefPostDataCToCpp() {} + virtual void Set(const std::wstring& url, const std::wstring& method, + CefRefPtr 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 element); - virtual bool AddElement(CefRefPtr 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 -{ -public: - CefPostDataElementCToCpp(cef_post_data_element_t* str) - : CefCToCpp(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 diff --git a/libcef_dll/ctocpp/stream_ctocpp.h b/libcef_dll/ctocpp/stream_ctocpp.h deleted file mode 100644 index 8501226b9..000000000 --- a/libcef_dll/ctocpp/stream_ctocpp.h +++ /dev/null @@ -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 -{ -public: - CefStreamReaderCToCpp(cef_stream_reader_t* str) - : CefCToCpp(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 -{ -public: - CefStreamWriterCToCpp(cef_stream_writer_t* str) - : CefCToCpp(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 diff --git a/libcef_dll/ctocpp/stream_reader_ctocpp.cc b/libcef_dll/ctocpp/stream_reader_ctocpp.cc new file mode 100644 index 000000000..0dbadeb9f --- /dev/null +++ b/libcef_dll/ctocpp/stream_reader_ctocpp.cc @@ -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::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::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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/stream_reader_ctocpp.h b/libcef_dll/ctocpp/stream_reader_ctocpp.h new file mode 100644 index 000000000..a60e133ec --- /dev/null +++ b/libcef_dll/ctocpp/stream_reader_ctocpp.h @@ -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 +{ +public: + CefStreamReaderCToCpp(cef_stream_reader_t* str) + : CefCToCpp( + 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 + diff --git a/libcef_dll/ctocpp/stream_ctocpp.cc b/libcef_dll/ctocpp/stream_writer_ctocpp.cc similarity index 53% rename from libcef_dll/ctocpp/stream_ctocpp.cc rename to libcef_dll/ctocpp/stream_writer_ctocpp.cc index cbb17f860..a3608560e 100644 --- a/libcef_dll/ctocpp/stream_ctocpp.cc +++ b/libcef_dll/ctocpp/stream_writer_ctocpp.cc @@ -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::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::DebugObjCt = 0; #endif + diff --git a/libcef_dll/ctocpp/stream_writer_ctocpp.h b/libcef_dll/ctocpp/stream_writer_ctocpp.h new file mode 100644 index 000000000..56ffbaa44 --- /dev/null +++ b/libcef_dll/ctocpp/stream_writer_ctocpp.h @@ -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 +{ +public: + CefStreamWriterCToCpp(cef_stream_writer_t* str) + : CefCToCpp( + 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 + diff --git a/libcef_dll/ctocpp/v8handler_ctocpp.cc b/libcef_dll/ctocpp/v8handler_ctocpp.cc index eb4ca6045..ed762f406 100644 --- a/libcef_dll/ctocpp/v8handler_ctocpp.cc +++ b/libcef_dll/ctocpp/v8handler_ctocpp.cc @@ -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 object, - CefV8ValueList& arguments, - CefRefPtr& retval, - std::wstring& exception) + CefRefPtr object, const CefV8ValueList& arguments, + CefRefPtr& 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(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::DebugObjCt - = 0; +long CefCToCpp::DebugObjCt = + 0; #endif + diff --git a/libcef_dll/ctocpp/v8handler_ctocpp.h b/libcef_dll/ctocpp/v8handler_ctocpp.h index cd61e06d4..995e5da37 100644 --- a/libcef_dll/ctocpp/v8handler_ctocpp.h +++ b/libcef_dll/ctocpp/v8handler_ctocpp.h @@ -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 { -public: - CefV8HandlerCToCpp(cef_v8handler_t* str) - : CefCToCpp(str) {} - virtual ~CefV8HandlerCToCpp() {} - +public: + CefV8HandlerCToCpp(cef_v8handler_t* str) + : CefCToCpp(str) {} + virtual ~CefV8HandlerCToCpp() {} + // CefV8Handler methods - virtual bool Execute(const std::wstring& name, - CefRefPtr object, - CefV8ValueList& arguments, - CefRefPtr& retval, - std::wstring& exception); -}; - - -#endif // BUILDING_CEF_SHARED -#endif // _V8HANDLER_CTOCPP_H + virtual bool Execute(const std::wstring& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + std::wstring& exception); +}; + +#endif // BUILDING_CEF_SHARED +#endif // _V8HANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/v8value_ctocpp.cc b/libcef_dll/ctocpp/v8value_ctocpp.cc index 6dfa0d565..b45a5ee3a 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.cc +++ b/libcef_dll/ctocpp/v8value_ctocpp.cc @@ -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::CreateUndefined() +{ + cef_v8value_t* impl = cef_v8value_create_undefined(); + if(impl) + return CefV8ValueCToCpp::Wrap(impl); + return NULL; +} + +CefRefPtr CefV8Value::CreateNull() +{ + cef_v8value_t* impl = cef_v8value_create_null(); + if(impl) + return CefV8ValueCToCpp::Wrap(impl); + return NULL; +} + +CefRefPtr CefV8Value::CreateBool(bool value) +{ + cef_v8value_t* impl = cef_v8value_create_bool(value); + if(impl) + return CefV8ValueCToCpp::Wrap(impl); + return NULL; +} + +CefRefPtr CefV8Value::CreateInt(int value) +{ + cef_v8value_t* impl = cef_v8value_create_int(value); + if(impl) + return CefV8ValueCToCpp::Wrap(impl); + return NULL; +} + +CefRefPtr CefV8Value::CreateDouble(double value) +{ + cef_v8value_t* impl = cef_v8value_create_double(value); + if(impl) + return CefV8ValueCToCpp::Wrap(impl); + return NULL; +} + +CefRefPtr 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::CreateObject(CefRefPtr 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::CreateArray() +{ + cef_v8value_t* impl = cef_v8value_create_array(); + if(impl) + return CefV8ValueCToCpp::Wrap(impl); + return NULL; +} + +CefRefPtr CefV8Value::CreateFunction(const std::wstring& name, + CefRefPtr 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 CefV8ValueCToCpp::GetValue(int index) return NULL; } -bool CefV8ValueCToCpp::SetValue(const std::wstring& key, CefRefPtr value) +bool CefV8ValueCToCpp::SetValue(const std::wstring& key, + CefRefPtr value) { if(CEF_MEMBER_MISSING(struct_, set_value_bykey)) return false; @@ -254,9 +351,8 @@ CefRefPtr CefV8ValueCToCpp::GetFunctionHandler() } bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr object, - CefV8ValueList& arguments, - CefRefPtr& retval, - std::wstring& exception) + const CefV8ValueList& arguments, CefRefPtr& retval, + std::wstring& exception) { if(CEF_MEMBER_MISSING(struct_, execute_function)) return RV_CONTINUE; @@ -273,7 +369,8 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr object, cef_string_t exceptionStr = NULL; int rv = struct_->execute_function(struct_, CefV8ValueCToCpp::Unwrap(object), - argsSize, argsStructPtr, &retvalStruct, &exceptionStr); + argsSize, const_cast(argsStructPtr), &retvalStruct, + &exceptionStr); if(retvalStruct) retval = CefV8ValueCToCpp::Wrap(retvalStruct); if(exceptionStr) { @@ -291,3 +388,4 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr object, #ifdef _DEBUG long CefCToCpp::DebugObjCt = 0; #endif + diff --git a/libcef_dll/ctocpp/v8value_ctocpp.h b/libcef_dll/ctocpp/v8value_ctocpp.h index d00acfdd0..72e3b7929 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.h +++ b/libcef_dll/ctocpp/v8value_ctocpp.h @@ -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 { -public: - CefV8ValueCToCpp(cef_v8value_t* str) - : CefCToCpp(str) {} - virtual ~CefV8ValueCToCpp() {} - +public: + CefV8ValueCToCpp(cef_v8value_t* str) + : CefCToCpp(str) {} + virtual ~CefV8ValueCToCpp() {} + // CefV8Value methods virtual bool IsUndefined(); virtual bool IsNull(); @@ -52,11 +58,10 @@ public: virtual std::wstring GetFunctionName(); virtual CefRefPtr GetFunctionHandler(); virtual bool ExecuteFunction(CefRefPtr object, - CefV8ValueList& arguments, - CefRefPtr& retval, - std::wstring& exception); -}; - - -#endif // USING_CEF_SHARED -#endif // _V8VALUE_CTOCPP_H + const CefV8ValueList& arguments, CefRefPtr& retval, + std::wstring& exception); +}; + +#endif // USING_CEF_SHARED +#endif // _V8VALUE_CTOCPP_H + diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index 308747d23..0ba2503ec 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -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 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 handlerPtr; - std::wstring urlStr; - CefWindowInfo wi = *windowInfo; - - if(handler) - handlerPtr = CefHandlerCToCpp::Wrap(handler); - if(url) - urlStr = url; - - CefRefPtr 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 impl = CefRequest::CreateRequest(); - if(impl.get()) - return CefRequestCppToC::Wrap(impl); - return NULL; -} - -CEF_EXPORT cef_post_data_t* cef_create_post_data() -{ - CefRefPtr 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 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 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 impl = CefStreamReader::CreateForData(data, size); - if(impl.get()) - return CefStreamReaderCppToC::Wrap(impl); - return NULL; -} - -CEF_EXPORT cef_v8value_t* cef_create_v8value_undefined() -{ - CefRefPtr impl = CefV8Value::CreateUndefined(); - if(impl.get()) - return CefV8ValueCppToC::Wrap(impl); - return NULL; -} - -CEF_EXPORT cef_v8value_t* cef_create_v8value_null() -{ - CefRefPtr impl = CefV8Value::CreateNull(); - if(impl.get()) - return CefV8ValueCppToC::Wrap(impl); - return NULL; -} - -CEF_EXPORT cef_v8value_t* cef_create_v8value_bool(int value) -{ - CefRefPtr 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 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 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 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 basePtr; - if(user_data) - basePtr = CefBaseCToCpp::Wrap(user_data); - - CefRefPtr impl = CefV8Value::CreateObject(basePtr); - if(impl.get()) - return CefV8ValueCppToC::Wrap(impl); - return NULL; -} - -CEF_EXPORT cef_v8value_t* cef_create_v8value_array() -{ - CefRefPtr 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 handlerPtr; - if(handler) - handlerPtr = CefV8HandlerCToCpp::Wrap(handler); - - CefRefPtr 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; diff --git a/libcef_dll/libcef_dll.vcproj b/libcef_dll/libcef_dll.vcproj index 184a2c7b7..d9e967617 100644 --- a/libcef_dll/libcef_dll.vcproj +++ b/libcef_dll/libcef_dll.vcproj @@ -254,6 +254,54 @@ RelativePath=".\cpptoc\frame_cpptoc.h" > + + + + + + + + + + + + + + + + + + + + @@ -279,7 +327,7 @@ > + + + + + + + + + + handler, - const std::wstring& url) -{ - return cef_create_browser(&windowInfo, popup, CefHandlerCppToC::Wrap(handler), - url.c_str()); -} - -CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, - bool popup, - CefRefPtr 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 CreateRequest() -{ - cef_request_t* impl = cef_create_request(); - if(impl) - return CefRequestCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CreatePostData() -{ - cef_post_data_t* impl = cef_create_post_data(); - if(impl) - return CefPostDataCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CreatePostDataElement() -{ - cef_post_data_element_t* impl = cef_create_post_data_element(); - if(impl) - return CefPostDataElementCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr 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::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::CreateUndefined() -{ - cef_v8value_t* impl = cef_create_v8value_undefined(); - if(impl) - return CefV8ValueCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CefV8Value::CreateNull() -{ - cef_v8value_t* impl = cef_create_v8value_null(); - if(impl) - return CefV8ValueCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CefV8Value::CreateBool(bool value) -{ - cef_v8value_t* impl = cef_create_v8value_bool(value); - if(impl) - return CefV8ValueCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CefV8Value::CreateInt(int value) -{ - cef_v8value_t* impl = cef_create_v8value_int(value); - if(impl) - return CefV8ValueCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CefV8Value::CreateDouble(double value) -{ - cef_v8value_t* impl = cef_create_v8value_double(value); - if(impl) - return CefV8ValueCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr 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::CreateObject(CefRefPtr 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::CreateArray() -{ - cef_v8value_t* impl = cef_create_v8value_array(); - if(impl) - return CefV8ValueCToCpp::Wrap(impl); - return NULL; -} - -CefRefPtr CefV8Value::CreateFunction(const std::wstring& name, - CefRefPtr 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; diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.vcproj b/libcef_dll/wrapper/libcef_dll_wrapper.vcproj index 6c5cb4408..d983c7043 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.vcproj +++ b/libcef_dll/wrapper/libcef_dll_wrapper.vcproj @@ -173,6 +173,22 @@ RelativePath="..\ctocpp\frame_ctocpp.h" > + + + + + + + + @@ -182,11 +198,19 @@ > + + + + object, - CefV8ValueList& arguments, + const CefV8ValueList& arguments, CefRefPtr& retval, std::wstring& exception) { @@ -285,7 +285,7 @@ public: // the method was handled. virtual bool Execute(const std::wstring& name, CefRefPtr object, - CefV8ValueList& arguments, + const CefV8ValueList& arguments, CefRefPtr& retval, std::wstring& exception) { diff --git a/tools/cef_parser.py b/tools/cef_parser.py new file mode 100644 index 000000000..68421e93f --- /dev/null +++ b/tools/cef_parser.py @@ -0,0 +1,1316 @@ +# 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 os +import re +import shutil +import string +import sys +import textwrap +import time + + +def notify(msg): + """ Display a message. """ + sys.stdout.write(' NOTE: '+msg+'\n') + + +def read_file(name, normalize = True): + """ Function for reading a file. """ + try: + f = open(name, 'r') + # read the data + data = f.read() + if normalize: + # normalize line endings + data = data.replace("\r\n", "\n") + return data + except IOError, (errno, strerror): + sys.stderr.write('Failed to read file '+filename+': '+strerror) + raise + else: + f.close() + +def write_file(name, data): + """ Function for writing a file. """ + notify('Writing file '+name) + try: + f = open(name, 'w') + # write the data + f.write(data) + except IOError, (errno, strerror): + sys.stderr.write('Failed to write file '+name+': '+strerror) + raise + else: + f.close() + +def file_exists(name): + """ Returns true if the file currently exists. """ + return os.path.exists(name) + +def backup_file(name): + """ Renames the file to a name that includes the current time stamp. """ + notify('Creating a backup of file '+name) + shutil.move(name, name+'.'+time.strftime('%Y-%m-%d-%H-%M-%S')) + + +def wrap_text(text, indent = '', maxchars = 80): + """ Wrap the text to the specified number of characters. If + necessary a line will be broken and wrapped after a word. + """ + result = '' + lines = textwrap.wrap(text, maxchars - len(indent)) + for line in lines: + result += indent+line+'\n' + return result + +def wrap_code(code, indent = ' ', maxchars = 80, splitchars = '(=,'): + """ Wrap the code lines to the specified number of characters. If + necessary a line will be broken and wrapped after one of the split + characters. + """ + output = '' + + # normalize line endings + code = code.replace("\r\n", "\n") + + # break the code chunk into lines + lines = string.split(code, '\n') + for line in lines: + if len(line) <= maxchars: + # line is short enough that it doesn't need to be wrapped + output += line + '\n' + continue + + # retrieve the whitespace at the beginning of the line for later use + # as padding + ws = '' + for char in line: + if char.isspace(): + ws += char + else: + break + + # iterate over all characters in the string keeping track of where the + # last valid break character was found and wrapping the line + # accordingly + lastsplit = 0 + nextsplit = -1 + splitct = 0 + pos = 0 + for char in line: + if splitchars.find(char) >= 0: + # a new split position has been found + nextsplit = pos + size = pos - lastsplit + 1 + if splitct > 0: + size += len(ws) + len(indent) + if size >= maxchars: + # the line is too long + section = line[lastsplit:nextsplit+1] + if len(section) > 0: + # output the line portion between the last split and the + # next split + if splitct > 0: + # start a new line and trim the line section + output += '\n'+ws+indent + section = string.strip(section) + output += section + lastsplit = nextsplit + 1 + splitct += 1 + pos += 1 + if len(line) - lastsplit > 0: + # output the remainder of the line + section = line[lastsplit:] + if splitct > 0: + # start a new line and trim the line section + output += '\n'+ws+indent + section = string.strip(section) + output += section + output += '\n' + + return output + +def get_capi_name(cppname, isclassname, prefix = None): + """ Convert a C++ CamelCaps name to a C API underscore name. """ + result = '' + lastchr = '' + for chr in cppname: + # add an underscore if the current character is an upper case letter + # and the last character was a lower case letter + if len(result) > 0 and not chr.isdigit() \ + and string.upper(chr) == chr \ + and not string.upper(lastchr) == lastchr: + result += '_' + result += string.lower(chr) + lastchr = chr + + if isclassname: + result += '_t' + + if not prefix is None: + if prefix[0:3] == 'cef': + # if the prefix name is duplicated in the function name + # remove that portion of the function name + subprefix = prefix[3:] + pos = result.find(subprefix) + if pos >= 0: + result = result[0:pos]+ result[pos+len(subprefix):] + result = prefix+'_'+result + + return result + +def get_prev_line(body, pos): + """ Retrieve the start and end positions and value for the line immediately + before the line containing the specified position. + """ + end = string.rfind(body, '\n', 0, pos) + start = body.rfind('\n', 0, end)+1 + line = body[start:end] + return { 'start' : start, 'end' : end, 'line' : line } + +def get_comment(body, name): + """ Retrieve the comment for a class or function. """ + result = [] + + pos = body.find(name) + while pos > 0: + data = get_prev_line(body, pos) + line = string.strip(data['line']) + pos = data['start'] + if len(line) == 0: + # check if the next previous line is a comment + prevdata = get_prev_line(body, pos) + if string.strip(prevdata['line'])[0:2] == '//': + result.append(None) + else: + break + elif line[0:2] == '/*': + continue + elif line[0:2] == '//': + result.append(line[3:]) + else: + break + + result.reverse() + return result + +def format_comment(comment, indent, translate_map = None, maxchars = 80): + """ Return the comments array as a formatted string. """ + result = '' + wrapme = '' + hasemptyline = False + for line in comment: + if line is None or len(line) == 0 or line[0:1] == ' ': + # the previous paragraph, if any, has ended + if len(wrapme) > 0: + if not translate_map is None: + # apply the translation + for key in translate_map.keys(): + wrapme = wrapme.replace(key, translate_map[key]) + # output the previous paragraph + result += wrap_text(wrapme, indent+'// ', maxchars) + wrapme = '' + + if not line is None: + if len(line) == 0 or line[0:1] == ' ': + # blank lines or anything that's further indented should be + # output as-is + result += indent+'//' + if len(line) > 0: + result += ' '+line + result += '\n' + else: + # add to the current paragraph + wrapme += line+' ' + else: + # output an empty line + hasemptyline = True + result += '\n' + + if len(wrapme) > 0: + if not translate_map is None: + # apply the translation + for key in translate_map.keys(): + wrapme = wrapme.replace(key, translate_map[key]) + # output the previous paragraph + result += wrap_text(wrapme, indent+'// ', maxchars) + + if hasemptyline: + # an empty line means a break between comments, so the comment is + # probably a section heading and should have an extra line before it + result = '\n' + result + return result + +def format_translation_changes(old, new): + """ Return a comment stating what is different between the old and new + function prototype parts. + """ + changed = False + result = '' + + # normalize C API attributes + oldargs = [x.replace('struct _', '') for x in old['args']] + oldretval = old['retval'].replace('struct _', '') + newargs = [x.replace('struct _', '') for x in new['args']] + newretval = new['retval'].replace('struct _', '') + + # check if the prototype has changed + oldset = set(oldargs) + newset = set(newargs) + if len(oldset.symmetric_difference(newset)) > 0: + changed = True + result += '\n // WARNING - CHANGED ATTRIBUTES' + + # in the implementation set only + oldonly = oldset.difference(newset) + for arg in oldonly: + result += '\n // REMOVED: '+arg + + # in the current set only + newonly = newset.difference(oldset) + for arg in newonly: + result += '\n // ADDED: '+arg + + # check if the return value has changed + if oldretval != newretval: + changed = True + result += '\n // WARNING - CHANGED RETURN VALUE'+ \ + '\n // WAS: '+old['retval']+ \ + '\n // NOW: '+new['retval'] + + if changed: + result += '\n #pragma message("Warning: "__FILE__": '+new['name']+ \ + ' prototype has changed")\n' + + return result + +def format_translation_includes(body): + """ Return the necessary list of includes based on the contents of the + body. + """ + result = '#include "../precompiled_libcef.h"\n' + + # identify what CppToC classes are being used + p = re.compile('([A-Za-z0-9_]{1,})CppToC') + list = sorted(set(p.findall(body))) + for item in list: + result += '#include "cpptoc/'+ \ + get_capi_name(item[3:], False)+'_cpptoc.h"\n' + + # identify what CToCpp classes are being used + p = re.compile('([A-Za-z0-9_]{1,})CToCpp') + list = sorted(set(p.findall(body))) + for item in list: + result += '#include "ctocpp/'+ \ + get_capi_name(item[3:], False)+'_ctocpp.h"\n' + + if body.find('transfer_') > 0: + result += '#include "../transfer_util.h"\n' + + return result + +def str_to_dict(str): + """ Convert a string to a dictionary. """ + dict = {} + parts = string.split(str, ',') + for part in parts: + part = string.strip(part) + if len(part) == 0: + continue + sparts = string.split(part, '=') + if len(sparts) != 2: + raise Exception('Invalid dictionary pair format: '+part) + dict[string.strip(sparts[0])] = string.strip(sparts[1]) + return dict + +def dict_to_str(dict): + """ Convert a dictionary to a string. """ + str = [] + for name in dict.keys(): + str.append(name+'='+dict[name]) + return string.join(str, ',') + + +# regex for matching comment-formatted attributes +_cre_attrib = '/\*--cef\(([A-Za-z0-9_ ,=]{0,})\)--\*/' +# regex for matching class and function names +_cre_cfname = '([A-Za-z0-9_]{1,})' +# regex for matching typedef values and function return values +_cre_retval = '([A-Za-z0-9_<>:,\*\&]{1,})' +# regex for matching function return value and name combination +_cre_func = '([A-Za-z][A-Za-z0-9_<>:,\*\& ]{1,})' +# regex for matching arbitrary whitespace +_cre_space = '[\s]{1,}' + + +def get_function_impls(content, ident): + """ Retrieve the function parts from the specified contents as a set of + return value, name, arguments and body. Ident must occur somewhere in + the value. + """ + # extract the functions + p = re.compile('\n'+_cre_func+'\((.*?)\)' + + _cre_space+'\{(.*?)\n\}', + re.MULTILINE | re.DOTALL) + list = p.findall(content) + + # build the function map with the function name as the key + result = [] + for retval, argval, body in list: + if retval.find(ident) < 0: + # the identifier was not found + continue + + # remove the identifier + retval = string.replace(retval, ident, '') + retval = string.strip(retval) + + # retrieve the function name + parts = string.split(retval, ' ') + name = parts[-1] + del parts[-1] + retval = string.join(parts, ' ') + + # parse the arguments + args = [] + for v in string.split(argval, ','): + v = string.strip(v) + if len(v) > 0: + args.append(v) + + result.append({ + 'retval' : string.strip(retval), + 'name' : name, + 'args' : args, + 'body' : body + }) + + return result + +def get_next_function_impl(existing, name): + result = None + for item in existing: + if item['name'] == name: + result = item + existing.remove(item) + break + return result + +class obj_header: + """ Class representing a C++ header file. """ + + def __init__(self, filename): + self.filename = filename; + + # read the input file into memory + data = read_file(filename) + + # extract global typedefs + p = re.compile('\ntypedef'+_cre_space+_cre_retval+ + _cre_space+_cre_cfname+';', + re.MULTILINE | re.DOTALL) + list = p.findall(data) + + # build the global typedef objects + self.typedefs = [] + for value, alias in list: + self.typedefs.append(obj_typedef(self, value, alias)) + + # extract global functions + p = re.compile('\n'+_cre_attrib+'\n'+_cre_func+'\((.*?)\)', + re.MULTILINE | re.DOTALL) + list = p.findall(data) + + # build the global function objects + self.funcs = [] + for attrib, retval, argval in list: + comment = get_comment(data, retval+'('+argval+');') + self.funcs.append(obj_function(self, attrib, retval, argval, + comment)) + + # extract classes + p = re.compile('\n'+_cre_attrib+ + '\nclass'+_cre_space+_cre_cfname+_cre_space+ + ':'+_cre_space+'public'+_cre_space+'CefBase'+ + '\n{(.*?)}', re.MULTILINE | re.DOTALL) + list = p.findall(data) + + # build the class objects + self.classes = [] + for attrib, name, body in list: + comment = get_comment(data, name+' : public CefBase') + self.classes.append( + obj_class(self, attrib, name, body, comment)) + + def __repr__(self): + result = '' + + if len(self.typedefs) > 0: + strlist = [] + for cls in self.typedefs: + strlist.append(str(cls)) + result += string.join(strlist, "\n") + "\n\n" + + if len(self.funcs) > 0: + strlist = [] + for cls in self.funcs: + strlist.append(str(cls)) + result += string.join(strlist, "\n") + "\n\n" + + if len(self.classes) > 0: + strlist = [] + for cls in self.classes: + strlist.append(str(cls)) + result += string.join(strlist, "\n") + + return result + + def get_file_name(self): + """ Return the file name. """ + return self.filename + + def get_typedefs(self): + """ Return the array of typedef objects. """ + return self.typedefs + + def get_funcs(self): + """ Return the array of function objects. """ + return self.funcs + + def get_classes(self): + """ Return the array of class objects. """ + return self.classes + + def get_class(self, classname, defined_structs = None): + """ Return the specified class or None if not found. """ + for cls in self.classes: + if cls.get_name() == classname: + return cls + elif not defined_structs is None: + defined_structs.append(cls.get_capi_name()) + return None + + def get_class_names(self): + """ Returns the names of all classes in this object. """ + result = [] + for cls in self.classes: + result.append(cls.get_name()) + return result + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + for cls in self.typedefs: + cls.get_types(list) + + for cls in self.classes: + cls.get_types(list) + + def get_alias_translation(self, alias): + """ Return a translation of alias to value based on typedef + statements. """ + for cls in self.typedefs: + if cls.alias == alias: + return cls.value + return None + + def get_analysis(self, value, named = True): + """ Return an analysis of the value based the header file context. """ + return obj_analysis([self], value, named) + + def get_defined_structs(self): + """ Return a list of names already defined structure names. """ + return ['cef_print_info_t', 'cef_window_info_t', + 'cef_handler_menuinfo_t', 'cef_base_t'] + + def get_capi_translations(self): + """ Return a dictionary that maps C++ terminology to C API terminology. + """ + # strings that will be changed in C++ comments + map = { + 'class' : 'structure', + 'Class' : 'Structure', + 'interface' : 'structure', + 'Interface' : 'Structure', + 'true' : 'true (1)', + 'false' : 'false (0)', + 'empty' : 'NULL', + 'method' : 'function' + } + + # add mappings for all classes and functions + funcs = self.get_funcs() + for func in funcs: + map[func.get_name()+'()'] = func.get_capi_name()+'()' + + classes = self.get_classes() + for cls in classes: + map[cls.get_name()] = cls.get_capi_name() + + funcs = cls.get_virtual_funcs() + for func in funcs: + map[func.get_name()+'()'] = func.get_capi_name()+'()' + + funcs = cls.get_static_funcs() + for func in funcs: + map[func.get_name()+'()'] = func.get_capi_name()+'()' + + return map + + +class obj_class: + """ Class representing a C++ class. """ + + def __init__(self, parent, attrib, name, body, comment): + if not isinstance(parent, obj_header): + raise Exception('Invalid parent object type') + + self.parent = parent + self.attribs = str_to_dict(attrib) + self.name = name + self.comment = comment + + # extract typedefs + p = re.compile('\n'+_cre_space+'typedef'+_cre_space+_cre_retval+ + _cre_space+_cre_cfname+';', + re.MULTILINE | re.DOTALL) + list = p.findall(body) + + # build the typedef objects + self.typedefs = [] + for value, alias in list: + self.typedefs.append(obj_typedef(self, value, alias)) + + # extract static functions + p = re.compile('\n'+_cre_space+_cre_attrib+'\n'+_cre_space+'static'+ + _cre_space+_cre_func+'\((.*?)\)', + re.MULTILINE | re.DOTALL) + list = p.findall(body) + + # build the static function objects + self.staticfuncs = [] + for attrib, retval, argval in list: + comment = get_comment(body, retval+'('+argval+');') + self.staticfuncs.append( + obj_function_static(self, attrib, retval, argval, comment)) + + # extract virtual functions + p = re.compile('\n'+_cre_space+_cre_attrib+'\n'+_cre_space+'virtual'+ + _cre_space+_cre_func+'\((.*?)\)', + re.MULTILINE | re.DOTALL) + list = p.findall(body) + + # build the virtual function objects + self.virtualfuncs = [] + for attrib, retval, argval in list: + comment = get_comment(body, retval+'('+argval+') =0;') + self.virtualfuncs.append( + obj_function_virtual(self, attrib, retval, argval, comment)) + + def __repr__(self): + result = '/* '+dict_to_str(self.attribs)+' */ class '+self.name+"\n{" + + if len(self.typedefs) > 0: + result += "\n\t" + strlist = [] + for cls in self.typedefs: + strlist.append(str(cls)) + result += string.join(strlist, "\n\t") + + if len(self.staticfuncs) > 0: + result += "\n\t" + strlist = [] + for cls in self.staticfuncs: + strlist.append(str(cls)) + result += string.join(strlist, "\n\t") + + if len(self.virtualfuncs) > 0: + result += "\n\t" + strlist = [] + for cls in self.virtualfuncs: + strlist.append(str(cls)) + result += string.join(strlist, "\n\t") + + result += "\n};\n" + return result + + def get_name(self): + """ Return the class name. """ + return self.name; + + def get_capi_name(self): + """ Return the CAPI structure name for this class. """ + return get_capi_name(self.name, True) + + def get_comment(self): + """ Return the class comment as an array of lines. """ + return self.comment + + def get_attribs(self): + """ Return the class attributes as a dictionary. """ + return self.attribs; + + def get_typedefs(self): + """ Return the array of typedef objects. """ + return self.typedefs; + + def get_static_funcs(self): + """ Return the array of static function objects. """ + return self.staticfuncs; + + def get_virtual_funcs(self): + """ Return the array of virtual function objects. """ + return self.virtualfuncs; + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + for cls in self.typedefs: + cls.get_types(list) + + for cls in self.staticfuncs: + cls.get_types(list) + + for cls in self.virtualfuncs: + cls.get_types(list) + + def get_alias_translation(self, alias): + for cls in self.typedefs: + if cls.alias == alias: + return cls.value + return None + + def get_analysis(self, value, named = True): + """ Return an analysis of the value based on the class definition + context. + """ + return obj_analysis([self, self.parent], value, named) + + def is_library_side(self): + """ Returns true if the class is implemented by the library. """ + return self.attribs['source'] == 'library' + + def is_client_side(self): + """ Returns true if the class is implemented by the client. """ + return self.attribs['source'] == 'client' + + +class obj_typedef: + """ Class representing a typedef statement. """ + + def __init__(self, parent, value, alias): + if not isinstance(parent, obj_header) \ + and not isinstance(parent, obj_class): + raise Exception('Invalid parent object type') + + self.parent = parent + self.alias = alias + self.value = self.parent.get_analysis(value, False) + + def __repr__(self): + return 'typedef '+self.value.get_type()+' '+self.alias+';' + + def get_alias(self): + """ Return the alias. """ + return self.alias + + def get_value(self): + """ Return an analysis of the value based on the class or header file + definition context. + """ + return self.value + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + name = self.value.get_type() + if not name in list: + list[name] = self.value; + + +class obj_function: + """ Class representing a function. """ + + def __init__(self, parent, attrib, retval, argval, comment): + self.parent = parent + self.attribs = str_to_dict(attrib) + self.retval = obj_argument(self, retval) + self.name = self.retval.remove_name() + self.comment = comment + + # build the argument objects + self.arguments = [] + arglist = string.split(argval, ',') + for arg in arglist: + arg = string.strip(arg) + if len(arg) > 0: + self.arguments.append(obj_argument(self, arg)) + + def __repr__(self): + return '/* '+dict_to_str(self.attribs)+' */ '+self.get_cpp_proto() + + def get_name(self): + """ Return the function name. """ + return self.name + + def get_capi_name(self, prefix = None): + """ Return the CAPI function name. """ + if 'capi_name' in self.attribs: + return self.attribs['capi_name'] + return get_capi_name(self.name, False, prefix) + + def get_comment(self): + """ Return the function comment as an array of lines. """ + return self.comment + + def get_attribs(self): + """ Return the function attributes as a dictionary. """ + return self.attribs + + def get_retval(self): + """ Return the return value object. """ + return self.retval + + def get_arguments(self): + """ Return the argument array. """ + return self.arguments + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + for cls in self.arguments: + cls.get_types(list) + + def get_capi_parts(self, defined_structs = [], prefix = None): + """ Return the parts of the C API function definition. """ + retval = '' + dict = self.retval.get_type().get_capi(defined_structs) + if dict['format'] == 'single': + retval = dict['value'] + + name = self.get_capi_name(prefix) + args = [] + + if isinstance(self, obj_function_virtual): + # virtual functions get themselves as the first argument + args.append('struct _'+self.parent.get_capi_name()+'* self') + + if len(self.arguments) > 0: + for cls in self.arguments: + type = cls.get_type() + dict = type.get_capi(defined_structs) + if dict['format'] == 'single': + args.append(dict['value']) + elif dict['format'] == 'multi-arg': + # add an additional argument for the size of the array + type = type.get_name() + if type[-1] == 's': + type = type[:-1] + args.append('size_t '+type+'Count') + args.append(dict['value']) + elif dict['format'] == 'multi-func': + # change the function to return one value of the + # required type based on an index parameter + type = type.get_name() + if type[-1] == 's': + type = type[:-1] + args.append('int '+type+'Index') + retval = dict['value'] + + return { 'retval' : retval, 'name' : name, 'args' : args } + + def get_capi_proto(self, defined_structs = [], prefix = None): + """ Return the prototype of the C API function. """ + parts = self.get_capi_parts(defined_structs, prefix) + result = parts['retval']+' '+parts['name']+ \ + '('+string.join(parts['args'], ', ')+')' + return result + + def get_cpp_parts(self, isimpl = False): + """ Return the parts of the C++ function definition. """ + retval = str(self.retval) + name = self.name + + args = [] + if len(self.arguments) > 0: + for cls in self.arguments: + args.append(str(cls)) + + if isimpl and isinstance(self, obj_function_virtual): + # enumeration return values must be qualified with the class name + type = self.get_retval().get_type() + if type.is_result_struct() and not type.is_byref() \ + and not type.is_byaddr(): + retval = self.parent.get_name()+'::'+retval + + return { 'retval' : retval, 'name' : name, 'args' : args } + + def get_cpp_proto(self, classname = None): + """ Return the prototype of the C++ function. """ + parts = self.get_cpp_parts() + result = parts['retval']+' ' + if not classname is None: + result += classname+'::' + result += parts['name']+'('+string.join(parts['args'], ', ')+')' + return result + + +class obj_function_static(obj_function): + """ Class representing a static function. """ + + def __init__(self, parent, attrib, retval, argval, comment): + if not isinstance(parent, obj_class): + raise Exception('Invalid parent object type') + obj_function.__init__(self, parent, attrib, retval, argval, comment) + + def __repr__(self): + return 'static '+obj_function.__repr__(self)+';' + + def get_capi_name(self, prefix = None): + """ Return the CAPI function name. """ + if prefix is None: + # by default static functions are prefixed with the class name + prefix = get_capi_name(self.parent.get_name(), False) + return obj_function.get_capi_name(self, prefix) + +class obj_function_virtual(obj_function): + """ Class representing a virtual function. """ + + def __init__(self, parent, attrib, retval, argval, comment): + if not isinstance(parent, obj_class): + raise Exception('Invalid parent object type') + obj_function.__init__(self, parent, attrib, retval, argval, comment) + + def __repr__(self): + return 'virtual '+obj_function.__repr__(self)+';' + + +class obj_argument: + """ Class representing a function argument. """ + + def __init__(self, parent, argval): + if not isinstance(parent, obj_function): + raise Exception('Invalid parent object type') + + self.parent = parent + self.type = self.parent.parent.get_analysis(argval) + + def __repr__(self): + result = '' + if self.type.is_const(): + result += 'const ' + result += self.type.get_type() + if self.type.is_byref(): + result += '&' + elif self.type.is_byaddr(): + result += '*' + if self.type.has_name(): + result += ' '+self.type.get_name() + return result + + def remove_name(self): + """ Remove and return the name value. """ + name = self.type.get_name() + self.type.name = None + return name + + def get_type(self): + """ Return an analysis of the argument type based on the class + definition context. + """ + return self.type + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + name = self.type.get_type() + if not name in list: + list[name] = self.type + + +class obj_analysis: + """ Class representing an analysis of a data type value. """ + + def __init__(self, scopelist, value, named): + self.value = value + self.result_type = 'unknown' + self.result_value = None + + # parse the argument string + partlist = string.split(string.strip(value)) + + if named == True: + # extract the name value + self.name = partlist[-1] + del partlist[-1] + else: + self.name = None + + if len(partlist) == 0: + raise Exception('Invalid argument value: '+value) + + # check const status + if partlist[0] == 'const': + self.isconst = True + del partlist[0] + else: + self.isconst = False + + # combine the data type + self.type = string.join(partlist, ' ') + + # extract the last character of the data type + endchar = self.type[-1] + + # check if the value is passed by reference + if endchar == '&': + self.isbyref = True + self.type = self.type[:-1] + else: + self.isbyref = False + + # check if the value is passed by address + if endchar == '*': + self.isbyaddr = True + self.type = self.type[:-1] + else: + self.isbyaddr = False + + # see if the value is directly identifiable + if self._check_advanced(self.type) == True: + return + + # not identifiable, so look it up + translation = None + for scope in scopelist: + if not isinstance(scope, obj_header) \ + and not isinstance(scope, obj_class): + raise Exception('Invalid scope object type') + translation = scope.get_alias_translation(self.type) + if not translation is None: + break + + if translation is None: + raise Exception('Failed to translate type: '+self.type) + + # the translation succeeded so keep the result + self.result_type = translation.result_type + self.result_value = translation.result_value + + def _check_advanced(self, value): + # check for vectors + if value.find('std::vector') == 0: + self.result_type = 'vector' + val = value[12:-1] + self.result_value = [ + self._get_basic(val) + ] + return True + + # check for maps + if value.find('std::map') == 0: + self.result_type = 'map' + vals = string.split(value[9:-1], ',') + if len(vals) == 2: + self.result_value = [ + self._get_basic(string.strip(vals[0])), + self._get_basic(string.strip(vals[1])) + ] + return True + + # check for basic types + basic = self._get_basic(value) + if not basic is None: + self.result_type = basic['result_type'] + self.result_value = basic['result_value'] + return True + + return False + + def _get_basic(self, value): + # check for string values + if value == "std::wstring": + return { + 'result_type' : 'string', + 'result_value' : None + } + + # check for simple direct translations + structuretypes = { + 'CefPrintInfo' : 'cef_print_info_t', + 'CefWindowInfo' : 'cef_window_info_t' + } + if value in structuretypes.keys(): + return { + 'result_type' : 'structure', + 'result_value' : structuretypes[value] + } + + # check for simple direct translations + simpletypes = { + 'void' : 'void', + 'int' : 'int', + 'double' : 'double', + 'long' : 'long', + 'size_t' : 'size_t', + 'bool' : 'int', + 'CefWindowHandle' : 'cef_window_handle_t' + } + if value in simpletypes.keys(): + return { + 'result_type' : 'simple', + 'result_value' : simpletypes[value] + } + + # check if already a C API structure + if value[-2:] == '_t': + return { + 'result_type' : 'structure', + 'result_value' : value + } + + # check for CEF reference pointers + p = re.compile('^CefRefPtr<(.*?)>$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'refptr', + 'result_value' : get_capi_name(list[0], True)+'*' + } + + return None + + def __repr__(self): + return '('+self.result_type+') '+str(self.result_value) + + def has_name(self): + """ Returns true if a name value exists. """ + return (not self.name is None) + + def get_name(self): + """ Return the name. """ + return self.name + + def get_value(self): + """ Return the name. """ + return self.value + + def get_type(self): + """ Return the type. """ + return self.type + + def is_const(self): + """ Returns true if the argument value is constant. """ + return self.isconst + + def is_byref(self): + """ Returns true if the argument is passed by reference. """ + return self.isbyref + + def is_byaddr(self): + """ Returns true if the argument is passed by address. """ + return self.isbyaddr + + def is_result_simple(self): + """ Returns true if this is a simple argument type. """ + return (self.result_type == 'simple') + + def get_result_simple_type(self): + """ Return the simple type. """ + result = '' + if self.is_const(): + result += 'const ' + result += self.result_value + if self.is_byaddr() or self.is_byref(): + result += '*' + return result + + def is_result_refptr(self): + """ Returns true if this is a reference pointer type. """ + return (self.result_type == 'refptr') + + def get_result_refptr_type(self, defined_structs = []): + """ Return the refptr type. """ + result = '' + if not self.result_value[:-1] in defined_structs: + result += 'struct _' + result += self.result_value + if self.is_byref() or self.is_byaddr(): + result += '*' + return result + + def is_result_struct(self): + """ Returns true if this is a structure type. """ + return (self.result_type == 'structure') + + def get_result_struct_type(self, defined_structs = []): + """ Return the structure or enumeration type. """ + result = '' + # structure values that are passed by reference or address must be + # structures and not enumerations + if self.is_byref() or self.is_byaddr(): + if self.is_const(): + result += 'const ' + if not self.result_value in defined_structs: + result += 'struct _' + elif not self.has_name(): + result += 'enum ' + result += self.result_value + if self.is_byref() or self.is_byaddr(): + result += '*' + return result + + def is_result_string(self): + """ Returns true if this is a string type. """ + return (self.result_type == 'string') + + def get_result_string_type(self): + """ Return the string type. """ + # if the string is a return value, or if the string is passed by + # reference or address then use the read-write string type + if not self.has_name(): + return 'cef_string_t' + elif not self.is_const() and (self.is_byref() or self.is_byaddr()): + return 'cef_string_t*' + return 'const wchar_t*' + + def is_result_vector(self): + """ Returns true if this is a vector type. """ + return (self.result_type == 'vector') + + def get_result_vector_type(self, defined_structs = []): + """ Return the vector type. """ + if not self.has_name(): + raise Exception('Cannot use vector as a return type') + + type = self.result_value[0]['result_type'] + value = self.result_value[0]['result_value'] + + result = {} + if type == 'string': + result['value'] = 'cef_string_list_t' + result['format'] = 'single' + return result + + if type == 'simple': + result['value'] = value + elif type == 'refptr': + str = '' + if self.is_const(): + str += 'const ' + if not value[:-1] in defined_structs: + str += 'struct _' + str += value + if self.is_const(): + str += '*' + result['value'] = str + else: + raise Exception('Unsupported vector type: '+type) + + if self.is_const(): + # const vector values must be passed as the value array parameter + # and a size parameter + result['format'] = 'multi-arg' + else: + # non-const vector values must be passed as one function to get the + # size and another function to get the element at a specified index + result['format'] = 'multi-func' + return result + + def is_result_map(self): + """ Returns true if this is a map type. """ + return (self.result_type == 'map') + + def get_result_map_type(self, defined_structs = []): + """ Return the map type. """ + if not self.has_name(): + raise Exception('Cannot use map as a return type') + if self.result_value[0]['result_type'] == 'string' \ + and self.result_value[1]['result_type'] == 'string': + return { + 'value' : 'cef_string_map_t', + 'format' : 'single' + } + raise Exception('Only mappings of strings to strings are supported') + + def get_capi(self, defined_structs = []): + """ Format the value for the C API. """ + result = '' + format = 'single' + if self.is_result_simple(): + result += self.get_result_simple_type() + elif self.is_result_refptr(): + result += self.get_result_refptr_type(defined_structs) + elif self.is_result_struct(): + result += self.get_result_struct_type(defined_structs) + elif self.is_result_string(): + result += self.get_result_string_type() + elif self.is_result_map(): + resdict = self.get_result_map_type(defined_structs) + if resdict['format'] == 'single': + result += resdict['value'] + else: + raise Exception('Only single-value map types are supported') + elif self.is_result_vector(): + resdict = self.get_result_vector_type(defined_structs) + if resdict['format'] != 'single': + format = resdict['format'] + result += resdict['value'] + + if self.has_name() and format != 'multi-func': + result += ' '+self.get_name(); + + return {'format' : format, 'value' : result} + + +# test the module +if __name__ == "__main__": + import pprint + 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]+' ') + sys.exit() + + pp = pprint.PrettyPrinter(indent=4) + + # create the header object + header = obj_header(sys.argv[1]) + + # output the type mapping + types = {} + header.get_types(types) + pp.pprint(types) + sys.stdout.write('\n') + + # output the parsed C++ data + sys.stdout.write(wrap_code(str(header), '\t')) + + # output the C API formatted data + defined_names = header.get_defined_structs() + result = '' + + # global functions + funcs = header.get_funcs() + if len(funcs) > 0: + for func in funcs: + result += func.get_capi_proto(defined_names)+';\n' + result += '\n' + + classes = header.get_classes() + for cls in classes: + # virtual functions are inside a structure + result += 'struct '+cls.get_capi_name()+'\n{\n' + funcs = cls.get_virtual_funcs() + if len(funcs) > 0: + for func in funcs: + result += '\t'+func.get_capi_proto(defined_names)+';\n' + result += '}\n\n' + + defined_names.append(cls.get_capi_name()) + + # static functions become global + funcs = cls.get_static_funcs() + if len(funcs) > 0: + for func in funcs: + result += func.get_capi_proto(defined_names)+';\n' + result += '\n' + sys.stdout.write(wrap_code(result, '\t')) diff --git a/tools/make_capi_header.py b/tools/make_capi_header.py new file mode 100644 index 000000000..afd3e6743 --- /dev/null +++ b/tools/make_capi_header.py @@ -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]+' ') + sys.exit() + + # create the header object + header = obj_header(sys.argv[1]) + + # dump the result to stdout + sys.stdout.write(make_capi_header(header)) diff --git a/tools/make_cpptoc_header.py b/tools/make_cpptoc_header.py new file mode 100644 index 000000000..9f0b0a17e --- /dev/null +++ b/tools/make_cpptoc_header.py @@ -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]+' ') + 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])) diff --git a/tools/make_cpptoc_impl.py b/tools/make_cpptoc_impl.py new file mode 100644 index 000000000..ca814e621 --- /dev/null +++ b/tools/make_cpptoc_impl.py @@ -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]+' ') + 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)) diff --git a/tools/make_ctocpp_header.py b/tools/make_ctocpp_header.py new file mode 100644 index 000000000..1eacb986c --- /dev/null +++ b/tools/make_ctocpp_header.py @@ -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]+' ') + 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])) diff --git a/tools/make_ctocpp_impl.py b/tools/make_ctocpp_impl.py new file mode 100644 index 000000000..f4f6beb39 --- /dev/null +++ b/tools/make_ctocpp_impl.py @@ -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]+' ') + 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)) diff --git a/tools/translator.README.txt b/tools/translator.README.txt new file mode 100644 index 000000000..c694b8d29 --- /dev/null +++ b/tools/translator.README.txt @@ -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 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 + C API: cef_browser_t* + + Smart pointer by reference type translation (argument only) + C++: CefRefPtr& value + C API: cef_browser_t** value + + String vector by reference type translation (argument only) + C++: std::vector& 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>& 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>& 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& 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. diff --git a/tools/translator.bat b/tools/translator.bat new file mode 100644 index 000000000..45141a0d0 --- /dev/null +++ b/tools/translator.bat @@ -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 \ No newline at end of file diff --git a/tools/translator.py b/tools/translator.py new file mode 100644 index 000000000..bed9c90b5 --- /dev/null +++ b/tools/translator.py @@ -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') + +