diff --git a/cef_paths.gypi b/cef_paths.gypi index fd396b44a..31a4b99f3 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -390,16 +390,26 @@ 'libcef_dll/cpptoc/thread_cpptoc.h', 'libcef_dll/cpptoc/test/translator_test_cpptoc.cc', 'libcef_dll/cpptoc/test/translator_test_cpptoc.h', - 'libcef_dll/ctocpp/test/translator_test_handler_ctocpp.cc', - 'libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h', - 'libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.cc', - 'libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h', - 'libcef_dll/cpptoc/test/translator_test_object_cpptoc.cc', - 'libcef_dll/cpptoc/test/translator_test_object_cpptoc.h', - 'libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.cc', - 'libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h', - 'libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.cc', - 'libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h', + 'libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h', + 'libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h', + 'libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h', + 'libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h', + 'libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h', 'libcef_dll/cpptoc/urlrequest_cpptoc.cc', 'libcef_dll/cpptoc/urlrequest_cpptoc.h', 'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc', @@ -652,16 +662,26 @@ 'libcef_dll/ctocpp/thread_ctocpp.h', 'libcef_dll/ctocpp/test/translator_test_ctocpp.cc', 'libcef_dll/ctocpp/test/translator_test_ctocpp.h', - 'libcef_dll/cpptoc/test/translator_test_handler_cpptoc.cc', - 'libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h', - 'libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.cc', - 'libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h', - 'libcef_dll/ctocpp/test/translator_test_object_ctocpp.cc', - 'libcef_dll/ctocpp/test/translator_test_object_ctocpp.h', - 'libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.cc', - 'libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h', - 'libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.cc', - 'libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h', + 'libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h', + 'libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.cc', + 'libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h', + 'libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h', + 'libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h', + 'libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.cc', + 'libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h', 'libcef_dll/ctocpp/urlrequest_ctocpp.cc', 'libcef_dll/ctocpp/urlrequest_ctocpp.h', 'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc', diff --git a/cef_paths2.gypi b/cef_paths2.gypi index bb7422a3e..432d882c3 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -89,11 +89,16 @@ ], 'libcef_sources_common': [ 'libcef_dll/cpptoc/cpptoc.h', + 'libcef_dll/cpptoc/cpptoc_scoped.h', 'libcef_dll/ctocpp/base_ctocpp.cc', 'libcef_dll/ctocpp/base_ctocpp.h', + 'libcef_dll/ctocpp/base_scoped_ctocpp.cc', + 'libcef_dll/ctocpp/base_scoped_ctocpp.h', 'libcef_dll/ctocpp/ctocpp.h', + 'libcef_dll/ctocpp/ctocpp_scoped.h', 'libcef_dll/libcef_dll.cc', 'libcef_dll/libcef_dll2.cc', + 'libcef_dll/ptr_util.h', 'libcef_dll/resource.h', 'libcef_dll/transfer_util.cc', 'libcef_dll/transfer_util.h', @@ -116,8 +121,13 @@ 'libcef_dll_wrapper_sources_common': [ 'libcef_dll/cpptoc/base_cpptoc.cc', 'libcef_dll/cpptoc/base_cpptoc.h', + 'libcef_dll/cpptoc/base_scoped_cpptoc.cc', + 'libcef_dll/cpptoc/base_scoped_cpptoc.h', 'libcef_dll/cpptoc/cpptoc.h', + 'libcef_dll/cpptoc/cpptoc_scoped.h', 'libcef_dll/ctocpp/ctocpp.h', + 'libcef_dll/ctocpp/ctocpp_scoped.h', + 'libcef_dll/ptr_util.h', 'libcef_dll/transfer_util.cc', 'libcef_dll/transfer_util.h', 'libcef_dll/wrapper_types.h', diff --git a/include/base/cef_build.h b/include/base/cef_build.h index 7cca8222e..81ee851f5 100644 --- a/include/base/cef_build.h +++ b/include/base/cef_build.h @@ -189,4 +189,13 @@ #endif #endif // OVERRIDE +// Check for C++11 template alias support which was added in VS2013 and GCC4.7. +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf +#if __cplusplus > 199711L || \ + (defined(_MSC_VER) && _MSC_VER >= 1800) || \ + (defined(__GNUC__) && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700)) +#define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT +#endif + #endif // CEF_INCLUDE_BASE_CEF_BUILD_H_ diff --git a/include/capi/cef_base_capi.h b/include/capi/cef_base_capi.h index ba3a39cb1..b12ff364e 100644 --- a/include/capi/cef_base_capi.h +++ b/include/capi/cef_base_capi.h @@ -45,8 +45,7 @@ extern "C" { #endif /// -// Structure defining the reference count implementation functions. All -// framework structures must include the cef_base_t structure first. +// All ref-counted framework structures must include this structure first. /// typedef struct _cef_base_t { /// @@ -74,6 +73,23 @@ typedef struct _cef_base_t { } cef_base_t; +/// +// All scoped framework structures must include this structure first. +/// +typedef struct _cef_base_scoped_t { + /// + // Size of the data structure. + /// + size_t size; + + /// + // Called to delete this object. May be NULL if the object is not owned. + /// + void (CEF_CALLBACK *del)(struct _cef_base_scoped_t* self); + +} cef_base_scoped_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) \ diff --git a/include/capi/cef_scheme_capi.h b/include/capi/cef_scheme_capi.h index f1ce06c5d..3c68e23b5 100644 --- a/include/capi/cef_scheme_capi.h +++ b/include/capi/cef_scheme_capi.h @@ -58,7 +58,7 @@ typedef struct _cef_scheme_registrar_t { /// // Base structure. /// - cef_base_t base; + cef_base_scoped_t base; /// // Register a custom scheme. This function should not be called for the built- diff --git a/include/capi/test/cef_translator_test_capi.h b/include/capi/test/cef_translator_test_capi.h index 23cff842c..1716fb390 100644 --- a/include/capi/test/cef_translator_test_capi.h +++ b/include/capi/test/cef_translator_test_capi.h @@ -49,10 +49,14 @@ extern "C" { #endif -struct _cef_translator_test_handler_child_t; -struct _cef_translator_test_handler_t; -struct _cef_translator_test_object_child_t; -struct _cef_translator_test_object_t; +struct _cef_translator_test_ref_ptr_client_child_t; +struct _cef_translator_test_ref_ptr_client_t; +struct _cef_translator_test_ref_ptr_library_child_t; +struct _cef_translator_test_ref_ptr_library_t; +struct _cef_translator_test_scoped_client_child_t; +struct _cef_translator_test_scoped_client_t; +struct _cef_translator_test_scoped_library_child_t; +struct _cef_translator_test_scoped_library_t; /// // Structure for testing all of the possible data transfer types. @@ -242,124 +246,271 @@ typedef struct _cef_translator_test_t { struct _cef_translator_test_t* self); - // LIBRARY-SIDE OBJECT VALUES + // LIBRARY-SIDE REFPTR VALUES /// // Return an new library-side object. /// - struct _cef_translator_test_object_t* (CEF_CALLBACK *get_object)( - struct _cef_translator_test_t* self, int val); + struct _cef_translator_test_ref_ptr_library_t* ( + CEF_CALLBACK *get_ref_ptr_library)(struct _cef_translator_test_t* self, + int val); /// // Set an object. Returns the value from - // cef_translator_test_object_t::get_value(). This tests input and execution - // of a library-side object type. + // cef_translator_test_ref_ptr_library_t::get_value(). This tests input and + // execution of a library-side object type. /// - int (CEF_CALLBACK *set_object)(struct _cef_translator_test_t* self, - struct _cef_translator_test_object_t* val); + int (CEF_CALLBACK *set_ref_ptr_library)(struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_t* val); /// // Set an object. Returns the object passed in. This tests input and output of // a library-side object type. /// - struct _cef_translator_test_object_t* (CEF_CALLBACK *set_object_and_return)( + struct _cef_translator_test_ref_ptr_library_t* ( + CEF_CALLBACK *set_ref_ptr_library_and_return)( struct _cef_translator_test_t* self, - struct _cef_translator_test_object_t* val); + struct _cef_translator_test_ref_ptr_library_t* val); /// // Set a child object. Returns the value from - // cef_translator_test_object_t::get_value(). This tests input of a library- - // side child object type and execution as the parent type. + // cef_translator_test_ref_ptr_library_t::get_value(). This tests input of a + // library- side child object type and execution as the parent type. /// - int (CEF_CALLBACK *set_child_object)(struct _cef_translator_test_t* self, - struct _cef_translator_test_object_child_t* val); + int (CEF_CALLBACK *set_child_ref_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_child_t* val); /// // Set a child object. Returns the object as the parent type. This tests input // of a library-side child object type and return as the parent type. /// - struct _cef_translator_test_object_t* ( - CEF_CALLBACK *set_child_object_and_return_parent)( + struct _cef_translator_test_ref_ptr_library_t* ( + CEF_CALLBACK *set_child_ref_ptr_library_and_return_parent)( struct _cef_translator_test_t* self, - struct _cef_translator_test_object_child_t* val); + struct _cef_translator_test_ref_ptr_library_child_t* val); /// // Set an object list vlaue. /// - int (CEF_CALLBACK *set_object_list)(struct _cef_translator_test_t* self, - size_t valCount, struct _cef_translator_test_object_t* const* val, - int val1, int val2); + int (CEF_CALLBACK *set_ref_ptr_library_list)( + struct _cef_translator_test_t* self, size_t valCount, + struct _cef_translator_test_ref_ptr_library_t* const* val, int val1, + int val2); /// // Return an object list value by out-param. /// - int (CEF_CALLBACK *get_object_list_by_ref)( + int (CEF_CALLBACK *get_ref_ptr_library_list_by_ref)( struct _cef_translator_test_t* self, size_t* valCount, - struct _cef_translator_test_object_t** val, int val1, int val2); + struct _cef_translator_test_ref_ptr_library_t** val, int val1, + int val2); /// // Return the number of object that will be output above. /// - size_t (CEF_CALLBACK *get_object_list_size)( + size_t (CEF_CALLBACK *get_ref_ptr_library_list_size)( struct _cef_translator_test_t* self); - // CLIENT-SIDE OBJECT VALUES + // CLIENT-SIDE REFPTR VALUES /// // Set an object. Returns the value from - // cef_translator_test_handler_t::get_value(). This tests input and execution - // of a client-side object type. + // cef_translator_test_ref_ptr_client_t::get_value(). This tests input and + // execution of a client-side object type. /// - int (CEF_CALLBACK *set_handler)(struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_t* val); + int (CEF_CALLBACK *set_ref_ptr_client)(struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_client_t* val); /// // Set an object. Returns the handler passed in. This tests input and output // of a client-side object type. /// - struct _cef_translator_test_handler_t* (CEF_CALLBACK *set_handler_and_return)( + struct _cef_translator_test_ref_ptr_client_t* ( + CEF_CALLBACK *set_ref_ptr_client_and_return)( struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_t* val); + struct _cef_translator_test_ref_ptr_client_t* val); /// // Set a child object. Returns the value from - // cef_translator_test_handler_t::get_value(). This tests input of a client- - // side child object type and execution as the parent type. + // cef_translator_test_ref_ptr_client_t::get_value(). This tests input of a + // client- side child object type and execution as the parent type. /// - int (CEF_CALLBACK *set_child_handler)(struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_child_t* val); + int (CEF_CALLBACK *set_child_ref_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_client_child_t* val); /// // Set a child object. Returns the object as the parent type. This tests input // of a client-side child object type and return as the parent type. /// - struct _cef_translator_test_handler_t* ( - CEF_CALLBACK *set_child_handler_and_return_parent)( + struct _cef_translator_test_ref_ptr_client_t* ( + CEF_CALLBACK *set_child_ref_ptr_client_and_return_parent)( struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_child_t* val); + struct _cef_translator_test_ref_ptr_client_child_t* val); /// // Set an object list vlaue. /// - int (CEF_CALLBACK *set_handler_list)(struct _cef_translator_test_t* self, - size_t valCount, struct _cef_translator_test_handler_t* const* val, - int val1, int val2); + int (CEF_CALLBACK *set_ref_ptr_client_list)( + struct _cef_translator_test_t* self, size_t valCount, + struct _cef_translator_test_ref_ptr_client_t* const* val, int val1, + int val2); /// // Return an object list value by out-param. /// - int (CEF_CALLBACK *get_handler_list_by_ref)( + int (CEF_CALLBACK *get_ref_ptr_client_list_by_ref)( struct _cef_translator_test_t* self, size_t* valCount, - struct _cef_translator_test_handler_t** val, - struct _cef_translator_test_handler_t* val1, - struct _cef_translator_test_handler_t* val2); + struct _cef_translator_test_ref_ptr_client_t** val, + struct _cef_translator_test_ref_ptr_client_t* val1, + struct _cef_translator_test_ref_ptr_client_t* val2); /// // Return the number of object that will be output above. /// - size_t (CEF_CALLBACK *get_handler_list_size)( + size_t (CEF_CALLBACK *get_ref_ptr_client_list_size)( struct _cef_translator_test_t* self); + + + // LIBRARY-SIDE OWNPTR VALUES + + /// + // Return an new library-side object. + /// + struct _cef_translator_test_scoped_library_t* ( + CEF_CALLBACK *get_own_ptr_library)(struct _cef_translator_test_t* self, + int val); + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input and + // execution of a library-side object type. + /// + int (CEF_CALLBACK *set_own_ptr_library)(struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val); + + /// + // Set an object. Returns the object passed in. This tests input and output of + // a library-side object type. + /// + struct _cef_translator_test_scoped_library_t* ( + CEF_CALLBACK *set_own_ptr_library_and_return)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input of a + // library- side child object type and execution as the parent type. + /// + int (CEF_CALLBACK *set_child_own_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val); + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a library-side child object type and return as the parent type. + /// + struct _cef_translator_test_scoped_library_t* ( + CEF_CALLBACK *set_child_own_ptr_library_and_return_parent)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val); + + + // CLIENT-SIDE OWNPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input and + // execution of a client-side object type. + /// + int (CEF_CALLBACK *set_own_ptr_client)(struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val); + + /// + // Set an object. Returns the handler passed in. This tests input and output + // of a client-side object type. + /// + struct _cef_translator_test_scoped_client_t* ( + CEF_CALLBACK *set_own_ptr_client_and_return)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input of a + // client- side child object type and execution as the parent type. + /// + int (CEF_CALLBACK *set_child_own_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val); + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a client-side child object type and return as the parent type. + /// + struct _cef_translator_test_scoped_client_t* ( + CEF_CALLBACK *set_child_own_ptr_client_and_return_parent)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val); + + + // LIBRARY-SIDE RAWPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input and + // execution of a library-side object type. + /// + int (CEF_CALLBACK *set_raw_ptr_library)(struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input of a + // library- side child object type and execution as the parent type. + /// + int (CEF_CALLBACK *set_child_raw_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val); + + /// + // Set an object list vlaue. + /// + int (CEF_CALLBACK *set_raw_ptr_library_list)( + struct _cef_translator_test_t* self, size_t valCount, + struct _cef_translator_test_scoped_library_t* const* val, int val1, + int val2); + + + // CLIENT-SIDE RAWPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input and + // execution of a client-side object type. + /// + int (CEF_CALLBACK *set_raw_ptr_client)(struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input of a + // client- side child object type and execution as the parent type. + /// + int (CEF_CALLBACK *set_child_raw_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val); + + /// + // Set an object list vlaue. + /// + int (CEF_CALLBACK *set_raw_ptr_client_list)( + struct _cef_translator_test_t* self, size_t valCount, + struct _cef_translator_test_scoped_client_t* const* val, int val1, + int val2); } cef_translator_test_t; @@ -370,9 +521,9 @@ CEF_EXPORT cef_translator_test_t* cef_translator_test_create(); /// -// Library-side test object. +// Library-side test object for RefPtr. /// -typedef struct _cef_translator_test_object_t { +typedef struct _cef_translator_test_ref_ptr_library_t { /// // Base structure. /// @@ -381,87 +532,89 @@ typedef struct _cef_translator_test_object_t { /// // Return a value. /// - int (CEF_CALLBACK *get_value)(struct _cef_translator_test_object_t* self); + int (CEF_CALLBACK *get_value)( + struct _cef_translator_test_ref_ptr_library_t* self); /// // Set a value. /// - void (CEF_CALLBACK *set_value)(struct _cef_translator_test_object_t* self, - int value); -} cef_translator_test_object_t; + void (CEF_CALLBACK *set_value)( + struct _cef_translator_test_ref_ptr_library_t* self, int value); +} cef_translator_test_ref_ptr_library_t; /// // Create the test object. /// -CEF_EXPORT cef_translator_test_object_t* cef_translator_test_object_create( +CEF_EXPORT cef_translator_test_ref_ptr_library_t* cef_translator_test_ref_ptr_library_create( int value); /// -// Library-side child test object. +// Library-side child test object for RefPtr. /// -typedef struct _cef_translator_test_object_child_t { +typedef struct _cef_translator_test_ref_ptr_library_child_t { /// // Base structure. /// - cef_translator_test_object_t base; + cef_translator_test_ref_ptr_library_t base; /// // Return a value. /// int (CEF_CALLBACK *get_other_value)( - struct _cef_translator_test_object_child_t* self); + struct _cef_translator_test_ref_ptr_library_child_t* self); /// // Set a value. /// void (CEF_CALLBACK *set_other_value)( - struct _cef_translator_test_object_child_t* self, int value); -} cef_translator_test_object_child_t; + struct _cef_translator_test_ref_ptr_library_child_t* self, int value); +} cef_translator_test_ref_ptr_library_child_t; /// // Create the test object. /// -CEF_EXPORT cef_translator_test_object_child_t* cef_translator_test_object_child_create( +CEF_EXPORT cef_translator_test_ref_ptr_library_child_t* cef_translator_test_ref_ptr_library_child_create( int value, int other_value); /// -// Another library-side child test object. +// Another library-side child test object for RefPtr. /// -typedef struct _cef_translator_test_object_child_child_t { +typedef struct _cef_translator_test_ref_ptr_library_child_child_t { /// // Base structure. /// - cef_translator_test_object_child_t base; + cef_translator_test_ref_ptr_library_child_t base; /// // Return a value. /// int (CEF_CALLBACK *get_other_other_value)( - struct _cef_translator_test_object_child_child_t* self); + struct _cef_translator_test_ref_ptr_library_child_child_t* self); /// // Set a value. /// void (CEF_CALLBACK *set_other_other_value)( - struct _cef_translator_test_object_child_child_t* self, int value); -} cef_translator_test_object_child_child_t; + struct _cef_translator_test_ref_ptr_library_child_child_t* self, + int value); +} cef_translator_test_ref_ptr_library_child_child_t; /// // Create the test object. /// -CEF_EXPORT cef_translator_test_object_child_child_t* cef_translator_test_object_child_child_create( +CEF_EXPORT cef_translator_test_ref_ptr_library_child_child_t* cef_translator_test_ref_ptr_library_child_child_create( int value, int other_value, int other_other_value); /// -// Client-side test object. +// Client-side test object for RefPtr. /// -typedef struct _cef_translator_test_handler_t { +typedef struct _cef_translator_test_ref_ptr_client_t { /// // Base structure. /// @@ -470,25 +623,151 @@ typedef struct _cef_translator_test_handler_t { /// // Return a value. /// - int (CEF_CALLBACK *get_value)(struct _cef_translator_test_handler_t* self); -} cef_translator_test_handler_t; + int (CEF_CALLBACK *get_value)( + struct _cef_translator_test_ref_ptr_client_t* self); +} cef_translator_test_ref_ptr_client_t; /// -// Client-side child test object. +// Client-side child test object for RefPtr. /// -typedef struct _cef_translator_test_handler_child_t { +typedef struct _cef_translator_test_ref_ptr_client_child_t { /// // Base structure. /// - cef_translator_test_handler_t base; + cef_translator_test_ref_ptr_client_t base; /// // Return a value. /// int (CEF_CALLBACK *get_other_value)( - struct _cef_translator_test_handler_child_t* self); -} cef_translator_test_handler_child_t; + struct _cef_translator_test_ref_ptr_client_child_t* self); +} cef_translator_test_ref_ptr_client_child_t; + + +/// +// Library-side test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_library_t { + /// + // Base structure. + /// + cef_base_scoped_t base; + + /// + // Return a value. + /// + int (CEF_CALLBACK *get_value)( + struct _cef_translator_test_scoped_library_t* self); + + /// + // Set a value. + /// + void (CEF_CALLBACK *set_value)( + struct _cef_translator_test_scoped_library_t* self, int value); +} cef_translator_test_scoped_library_t; + + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_scoped_library_t* cef_translator_test_scoped_library_create( + int value); + + +/// +// Library-side child test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_library_child_t { + /// + // Base structure. + /// + cef_translator_test_scoped_library_t base; + + /// + // Return a value. + /// + int (CEF_CALLBACK *get_other_value)( + struct _cef_translator_test_scoped_library_child_t* self); + + /// + // Set a value. + /// + void (CEF_CALLBACK *set_other_value)( + struct _cef_translator_test_scoped_library_child_t* self, int value); +} cef_translator_test_scoped_library_child_t; + + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_scoped_library_child_t* cef_translator_test_scoped_library_child_create( + int value, int other_value); + + +/// +// Another library-side child test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_library_child_child_t { + /// + // Base structure. + /// + cef_translator_test_scoped_library_child_t base; + + /// + // Return a value. + /// + int (CEF_CALLBACK *get_other_other_value)( + struct _cef_translator_test_scoped_library_child_child_t* self); + + /// + // Set a value. + /// + void (CEF_CALLBACK *set_other_other_value)( + struct _cef_translator_test_scoped_library_child_child_t* self, + int value); +} cef_translator_test_scoped_library_child_child_t; + + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_scoped_library_child_child_t* cef_translator_test_scoped_library_child_child_create( + int value, int other_value, int other_other_value); + + +/// +// Client-side test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_client_t { + /// + // Base structure. + /// + cef_base_scoped_t base; + + /// + // Return a value. + /// + int (CEF_CALLBACK *get_value)( + struct _cef_translator_test_scoped_client_t* self); +} cef_translator_test_scoped_client_t; + + +/// +// Client-side child test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_client_child_t { + /// + // Base structure. + /// + cef_translator_test_scoped_client_t base; + + /// + // Return a value. + /// + int (CEF_CALLBACK *get_other_value)( + struct _cef_translator_test_scoped_client_child_t* self); +} cef_translator_test_scoped_client_child_t; #ifdef __cplusplus diff --git a/include/cef_app.h b/include/cef_app.h index 098b6d756..cc5cb91cc 100644 --- a/include/cef_app.h +++ b/include/cef_app.h @@ -170,7 +170,7 @@ class CefApp : public virtual CefBase { /// /*--cef()--*/ virtual void OnRegisterCustomSchemes( - CefRefPtr registrar) { + CefRawPtr registrar) { } /// diff --git a/include/cef_base.h b/include/cef_base.h index c9213588a..8a7b5b752 100644 --- a/include/cef_base.h +++ b/include/cef_base.h @@ -48,8 +48,7 @@ #endif /// -// Interface defining the reference count implementation methods. All framework -// classes must extend the CefBase class. +// All ref-counted framework classes must extend this class. /// class CefBase { public: @@ -74,6 +73,14 @@ class CefBase { virtual ~CefBase() {} }; +/// +// All scoped framework classes must extend this class. +/// +class CefBaseScoped { + public: + virtual ~CefBaseScoped() {} +}; + /// // Class that implements atomic reference counting. /// diff --git a/include/cef_scheme.h b/include/cef_scheme.h index ec9f33e10..5861d85b1 100644 --- a/include/cef_scheme.h +++ b/include/cef_scheme.h @@ -82,7 +82,7 @@ bool CefClearSchemeHandlerFactories(); // Class that manages custom scheme registrations. /// /*--cef(source=library)--*/ -class CefSchemeRegistrar : public virtual CefBase { +class CefSchemeRegistrar : public CefBaseScoped { public: /// // Register a custom scheme. This method should not be called for the built-in diff --git a/include/internal/cef_ptr.h b/include/internal/cef_ptr.h index e38543911..7874699f5 100644 --- a/include/internal/cef_ptr.h +++ b/include/internal/cef_ptr.h @@ -32,8 +32,15 @@ #define CEF_INCLUDE_INTERNAL_CEF_PTR_H_ #pragma once +#include "include/base/cef_build.h" #include "include/base/cef_ref_counted.h" +#if defined(USING_CHROMIUM_INCLUDES) +#include // For std::unique_ptr. +#else +#include "include/base/cef_scoped_ptr.h" +#endif + /// // Smart pointer implementation that is an alias of scoped_refptr from // include/base/cef_ref_counted.h. @@ -143,19 +150,83 @@ // //

/// +#if defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT) template -class CefRefPtr : public scoped_refptr { +using CefRefPtr = scoped_refptr; +#else +// When template aliases are not supported use a define instead of subclassing +// because it's otherwise hard to get the constructors to behave correctly. +#define CefRefPtr scoped_refptr +#endif + + +/// +// A CefOwnPtr is like a T*, except that the destructor of CefOwnPtr +// automatically deletes the pointer it holds (if any). That is, CefOwnPtr +// owns the T object that it points to. Like a T*, a CefOwnPtr may hold +// either NULL or a pointer to a T object. Also like T*, CefOwnPtr is +// thread-compatible, and once you dereference it, you get the thread safety +// guarantees of T. +/// +#if defined(USING_CHROMIUM_INCLUDES) +// Implementation-side code uses std::unique_ptr instead of scoped_ptr. +template > +using CefOwnPtr = std::unique_ptr; +#elif defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT) +template > +using CefOwnPtr = scoped_ptr; +#else +// When template aliases are not supported use a define instead of subclassing +// because it's otherwise hard to get the constructors to behave correctly. +#define CefOwnPtr scoped_ptr +#endif + + +/// +// A CefRawPtr is the same as T* +/// +#if defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT) +template +using CefRawPtr = T*; +#else +// Simple wrapper implementation that behaves as much like T* as possible. +template +class CefRawPtr { public: - typedef scoped_refptr parent; - - CefRefPtr() : parent() {} - - CefRefPtr(T* p) : parent(p) {} - - CefRefPtr(const scoped_refptr& r) : parent(r) {} + CefRawPtr() : ptr_(nullptr) {} + CefRawPtr(T* p) : ptr_(p) {} + CefRawPtr(const CefRawPtr& r) : ptr_(r.ptr_) {} template - CefRefPtr(const scoped_refptr& r) : parent(r) {} + CefRawPtr(const CefRawPtr& r) : ptr_(r.get()) {} + + T* get() const { return ptr_; } + + // Allow CefRawPtr to be used in boolean expression and comparison operations. + operator T*() const { return ptr_; } + + T* operator->() const { + assert(ptr_ != NULL); + return ptr_; + } + + CefRawPtr& operator=(T* p) { + ptr_ = p; + return *this; + } + + CefRawPtr& operator=(const CefRawPtr& r) { + return *this = r.ptr_; + } + + template + CefRawPtr& operator=(const CefRawPtr& r) { + return *this = r.get(); + } + + private: + T* ptr_; }; +#endif #endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_ diff --git a/include/test/cef_translator_test.h b/include/test/cef_translator_test.h index c9398dad9..9c5d4288d 100644 --- a/include/test/cef_translator_test.h +++ b/include/test/cef_translator_test.h @@ -53,10 +53,14 @@ #include "include/cef_base.h" -class CefTranslatorTestHandler; -class CefTranslatorTestHandlerChild; -class CefTranslatorTestObject; -class CefTranslatorTestObjectChild; +class CefTranslatorTestRefPtrClient; +class CefTranslatorTestRefPtrClientChild; +class CefTranslatorTestRefPtrLibrary; +class CefTranslatorTestRefPtrLibraryChild; +class CefTranslatorTestScopedClient; +class CefTranslatorTestScopedClientChild; +class CefTranslatorTestScopedLibrary; +class CefTranslatorTestScopedLibraryChild; // Test values. #define TEST_INT_VAL 5 @@ -309,146 +313,311 @@ class CefTranslatorTest : public CefBase { virtual size_t GetPointListSize() = 0; - // LIBRARY-SIDE OBJECT VALUES + // LIBRARY-SIDE REFPTR VALUES /// // Return an new library-side object. /// /*--cef()--*/ - virtual CefRefPtr GetObject(int val) =0; + virtual CefRefPtr GetRefPtrLibrary( + int val) =0; /// - // Set an object. Returns the value from CefTranslatorTestObject::GetValue(). + // Set an object. Returns the value from + // CefTranslatorTestRefPtrLibrary::GetValue(). // This tests input and execution of a library-side object type. /// /*--cef()--*/ - virtual int SetObject(CefRefPtr val) =0; + virtual int SetRefPtrLibrary( + CefRefPtr val) =0; /// // Set an object. Returns the object passed in. This tests input and output // of a library-side object type. /// /*--cef()--*/ - virtual CefRefPtr SetObjectAndReturn( - CefRefPtr val) =0; + virtual CefRefPtr SetRefPtrLibraryAndReturn( + CefRefPtr val) =0; /// // Set a child object. Returns the value from - // CefTranslatorTestObject::GetValue(). This tests input of a library-side - // child object type and execution as the parent type. + // CefTranslatorTestRefPtrLibrary::GetValue(). This tests input of a library- + // side child object type and execution as the parent type. /// /*--cef()--*/ - virtual int SetChildObject(CefRefPtr val) =0; + virtual int SetChildRefPtrLibrary( + CefRefPtr val) =0; /// // Set a child object. Returns the object as the parent type. This tests input // of a library-side child object type and return as the parent type. /// /*--cef()--*/ - virtual CefRefPtr SetChildObjectAndReturnParent( - CefRefPtr val) =0; + virtual CefRefPtr + SetChildRefPtrLibraryAndReturnParent( + CefRefPtr val) =0; - // LIBRARY-SIDE OBJECT LIST VALUES + // LIBRARY-SIDE REFPTR LIST VALUES // Test both with and without a typedef. - typedef std::vector > ObjectList; + typedef std::vector > + RefPtrLibraryList; /// // Set an object list vlaue. /// /*--cef()--*/ - virtual bool SetObjectList( - const std::vector >& val, + virtual bool SetRefPtrLibraryList( + const std::vector >& val, int val1, int val2) =0; /// // Return an object list value by out-param. /// - /*--cef(count_func=val:GetObjectListSize)--*/ - virtual bool GetObjectListByRef(ObjectList& val, int val1, int val2) =0; + /*--cef(count_func=val:GetRefPtrLibraryListSize)--*/ + virtual bool GetRefPtrLibraryListByRef(RefPtrLibraryList& val, int val1, + int val2) =0; /// // Return the number of object that will be output above. /// /*--cef()--*/ - virtual size_t GetObjectListSize() = 0; + virtual size_t GetRefPtrLibraryListSize() = 0; - // CLIENT-SIDE OBJECT VALUES + // CLIENT-SIDE REFPTR VALUES /// - // Set an object. Returns the value from CefTranslatorTestHandler::GetValue(). + // Set an object. Returns the value from + // CefTranslatorTestRefPtrClient::GetValue(). // This tests input and execution of a client-side object type. /// /*--cef()--*/ - virtual int SetHandler(CefRefPtr val) =0; + virtual int SetRefPtrClient(CefRefPtr val) =0; /// // Set an object. Returns the handler passed in. This tests input and output // of a client-side object type. /// /*--cef()--*/ - virtual CefRefPtr SetHandlerAndReturn( - CefRefPtr val) =0; + virtual CefRefPtr SetRefPtrClientAndReturn( + CefRefPtr val) =0; /// // Set a child object. Returns the value from - // CefTranslatorTestHandler::GetValue(). This tests input of a client-side - // child object type and execution as the parent type. + // CefTranslatorTestRefPtrClient::GetValue(). This tests input of a client- + // side child object type and execution as the parent type. /// /*--cef()--*/ - virtual int SetChildHandler(CefRefPtr val) =0; + virtual int SetChildRefPtrClient( + CefRefPtr val) =0; /// // Set a child object. Returns the object as the parent type. This tests // input of a client-side child object type and return as the parent type. /// /*--cef()--*/ - virtual CefRefPtr SetChildHandlerAndReturnParent( - CefRefPtr val) =0; + virtual CefRefPtr + SetChildRefPtrClientAndReturnParent( + CefRefPtr val) =0; - // CLIENT-SIDE OBJECT LIST VALUES + // CLIENT-SIDE REFPTR LIST VALUES // Test both with and without a typedef. - typedef std::vector > HandlerList; + typedef std::vector > + RefPtrClientList; /// // Set an object list vlaue. /// /*--cef()--*/ - virtual bool SetHandlerList( - const std::vector >& val, + virtual bool SetRefPtrClientList( + const std::vector >& val, int val1, int val2) =0; /// // Return an object list value by out-param. /// - /*--cef(count_func=val:GetObjectListSize)--*/ - virtual bool GetHandlerListByRef( - HandlerList& val, - CefRefPtr val1, - CefRefPtr val2) =0; + /*--cef(count_func=val:GetRefPtrLibraryListSize)--*/ + virtual bool GetRefPtrClientListByRef( + RefPtrClientList& val, + CefRefPtr val1, + CefRefPtr val2) =0; /// // Return the number of object that will be output above. /// /*--cef()--*/ - virtual size_t GetHandlerListSize() = 0; + virtual size_t GetRefPtrClientListSize() = 0; + + + // LIBRARY-SIDE OWNPTR VALUES + + /// + // Return an new library-side object. + /// + /*--cef()--*/ + virtual CefOwnPtr GetOwnPtrLibrary( + int val) =0; + + /// + // Set an object. Returns the value from + // CefTranslatorTestScopedLibrary::GetValue(). + // This tests input and execution of a library-side object type. + /// + /*--cef()--*/ + virtual int SetOwnPtrLibrary( + CefOwnPtr val) =0; + + /// + // Set an object. Returns the object passed in. This tests input and output + // of a library-side object type. + /// + /*--cef()--*/ + virtual CefOwnPtr SetOwnPtrLibraryAndReturn( + CefOwnPtr val) =0; + + /// + // Set a child object. Returns the value from + // CefTranslatorTestScopedLibrary::GetValue(). This tests input of a library- + // side child object type and execution as the parent type. + /// + /*--cef()--*/ + virtual int SetChildOwnPtrLibrary( + CefOwnPtr val) =0; + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a library-side child object type and return as the parent type. + /// + /*--cef()--*/ + virtual CefOwnPtr + SetChildOwnPtrLibraryAndReturnParent( + CefOwnPtr val) =0; + + + // CLIENT-SIDE OWNPTR VALUES + + /// + // Set an object. Returns the value from + // CefTranslatorTestScopedClient::GetValue(). + // This tests input and execution of a client-side object type. + /// + /*--cef()--*/ + virtual int SetOwnPtrClient(CefOwnPtr val) =0; + + /// + // Set an object. Returns the handler passed in. This tests input and output + // of a client-side object type. + /// + /*--cef()--*/ + virtual CefOwnPtr SetOwnPtrClientAndReturn( + CefOwnPtr val) =0; + + /// + // Set a child object. Returns the value from + // CefTranslatorTestScopedClient::GetValue(). This tests input of a client- + // side child object type and execution as the parent type. + /// + /*--cef()--*/ + virtual int SetChildOwnPtrClient( + CefOwnPtr val) =0; + + /// + // Set a child object. Returns the object as the parent type. This tests + // input of a client-side child object type and return as the parent type. + /// + /*--cef()--*/ + virtual CefOwnPtr + SetChildOwnPtrClientAndReturnParent( + CefOwnPtr val) =0; + + + // LIBRARY-SIDE RAWPTR VALUES + + /// + // Set an object. Returns the value from + // CefTranslatorTestScopedLibrary::GetValue(). + // This tests input and execution of a library-side object type. + /// + /*--cef()--*/ + virtual int SetRawPtrLibrary( + CefRawPtr val) =0; + + /// + // Set a child object. Returns the value from + // CefTranslatorTestScopedLibrary::GetValue(). This tests input of a library- + // side child object type and execution as the parent type. + /// + /*--cef()--*/ + virtual int SetChildRawPtrLibrary( + CefRawPtr val) =0; + + + // LIBRARY-SIDE RAWPTR LIST VALUES + + // Test both with and without a typedef. + typedef std::vector > + RawPtrLibraryList; + + /// + // Set an object list vlaue. + /// + /*--cef()--*/ + virtual bool SetRawPtrLibraryList( + const std::vector >& val, + int val1, int val2) =0; + + + // CLIENT-SIDE RAWPTR VALUES + + /// + // Set an object. Returns the value from + // CefTranslatorTestScopedClient::GetValue(). + // This tests input and execution of a client-side object type. + /// + /*--cef()--*/ + virtual int SetRawPtrClient(CefRawPtr val) =0; + + /// + // Set a child object. Returns the value from + // CefTranslatorTestScopedClient::GetValue(). This tests input of a client- + // side child object type and execution as the parent type. + /// + /*--cef()--*/ + virtual int SetChildRawPtrClient( + CefRawPtr val) =0; + + + // CLIENT-SIDE RAWPTR LIST VALUES + + // Test both with and without a typedef. + typedef std::vector > + RawPtrClientList; + + /// + // Set an object list vlaue. + /// + /*--cef()--*/ + virtual bool SetRawPtrClientList( + const std::vector >& val, + int val1, int val2) =0; }; + /// -// Library-side test object. +// Library-side test object for RefPtr. /// /*--cef(source=library,no_debugct_check)--*/ -class CefTranslatorTestObject : public CefBase { +class CefTranslatorTestRefPtrLibrary : public CefBase { public: /// // Create the test object. /// /*--cef()--*/ - static CefRefPtr Create(int value); + static CefRefPtr Create(int value); /// // Return a value. @@ -464,17 +633,19 @@ class CefTranslatorTestObject : public CefBase { }; /// -// Library-side child test object. +// Library-side child test object for RefPtr. /// /*--cef(source=library,no_debugct_check)--*/ -class CefTranslatorTestObjectChild : public CefTranslatorTestObject { +class CefTranslatorTestRefPtrLibraryChild : + public CefTranslatorTestRefPtrLibrary { public: /// // Create the test object. /// /*--cef()--*/ - static CefRefPtr Create(int value, - int other_value); + static CefRefPtr Create( + int value, + int other_value); /// // Return a value. @@ -490,16 +661,17 @@ class CefTranslatorTestObjectChild : public CefTranslatorTestObject { }; /// -// Another library-side child test object. +// Another library-side child test object for RefPtr. /// /*--cef(source=library,no_debugct_check)--*/ -class CefTranslatorTestObjectChildChild : public CefTranslatorTestObjectChild { +class CefTranslatorTestRefPtrLibraryChildChild : + public CefTranslatorTestRefPtrLibraryChild { public: /// // Create the test object. /// /*--cef()--*/ - static CefRefPtr Create( + static CefRefPtr Create( int value, int other_value, int other_other_value); @@ -518,10 +690,10 @@ class CefTranslatorTestObjectChildChild : public CefTranslatorTestObjectChild { }; /// -// Client-side test object. +// Client-side test object for RefPtr. /// /*--cef(source=client,no_debugct_check)--*/ -class CefTranslatorTestHandler : public virtual CefBase { +class CefTranslatorTestRefPtrClient : public virtual CefBase { public: /// // Return a value. @@ -531,10 +703,121 @@ class CefTranslatorTestHandler : public virtual CefBase { }; /// -// Client-side child test object. +// Client-side child test object for RefPtr. /// /*--cef(source=client,no_debugct_check)--*/ -class CefTranslatorTestHandlerChild : public CefTranslatorTestHandler { +class CefTranslatorTestRefPtrClientChild : + public CefTranslatorTestRefPtrClient { + public: + /// + // Return a value. + /// + /*--cef()--*/ + virtual int GetOtherValue() =0; +}; + + +/// +// Library-side test object for OwnPtr/RawPtr. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefTranslatorTestScopedLibrary : public CefBaseScoped { + public: + /// + // Create the test object. + /// + /*--cef()--*/ + static CefOwnPtr Create(int value); + + /// + // Return a value. + /// + /*--cef()--*/ + virtual int GetValue() =0; + + /// + // Set a value. + /// + /*--cef()--*/ + virtual void SetValue(int value) =0; +}; + +/// +// Library-side child test object for OwnPtr/RawPtr. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefTranslatorTestScopedLibraryChild : + public CefTranslatorTestScopedLibrary { + public: + /// + // Create the test object. + /// + /*--cef()--*/ + static CefOwnPtr Create( + int value, + int other_value); + + /// + // Return a value. + /// + /*--cef()--*/ + virtual int GetOtherValue() =0; + + /// + // Set a value. + /// + /*--cef()--*/ + virtual void SetOtherValue(int value) =0; +}; + +/// +// Another library-side child test object for OwnPtr/RawPtr. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefTranslatorTestScopedLibraryChildChild : + public CefTranslatorTestScopedLibraryChild { + public: + /// + // Create the test object. + /// + /*--cef()--*/ + static CefOwnPtr Create( + int value, + int other_value, + int other_other_value); + + /// + // Return a value. + /// + /*--cef()--*/ + virtual int GetOtherOtherValue() =0; + + /// + // Set a value. + /// + /*--cef()--*/ + virtual void SetOtherOtherValue(int value) =0; +}; + +/// +// Client-side test object for OwnPtr/RawPtr. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefTranslatorTestScopedClient : public virtual CefBaseScoped { + public: + /// + // Return a value. + /// + /*--cef()--*/ + virtual int GetValue() =0; +}; + +/// +// Client-side child test object for OwnPtr/RawPtr. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefTranslatorTestScopedClientChild : + public CefTranslatorTestScopedClient { public: /// // Return a value. diff --git a/libcef/common/content_client.cc b/libcef/common/content_client.cc index 8f48e9ee0..8b641ae14 100644 --- a/libcef/common/content_client.cc +++ b/libcef/common/content_client.cc @@ -220,14 +220,9 @@ void CefContentClient::AddAdditionalSchemes(Schemes* schemes) { DCHECK(!scheme_info_list_locked_); if (application_.get()) { - CefRefPtr schemeRegistrar( - new CefSchemeRegistrarImpl()); - application_->OnRegisterCustomSchemes(schemeRegistrar.get()); - schemeRegistrar->GetSchemes(schemes); - - // No references to the registar should be kept. - schemeRegistrar->Detach(); - DCHECK(schemeRegistrar->VerifyRefCount()); + CefSchemeRegistrarImpl schemeRegistrar; + application_->OnRegisterCustomSchemes(&schemeRegistrar); + schemeRegistrar.GetSchemes(schemes); } scheme::AddInternalSchemes(schemes); diff --git a/libcef/common/scheme_registrar_impl.cc b/libcef/common/scheme_registrar_impl.cc index 4d3f87c1a..00b8daa0c 100644 --- a/libcef/common/scheme_registrar_impl.cc +++ b/libcef/common/scheme_registrar_impl.cc @@ -24,8 +24,7 @@ void AppendArray(const std::vector& source, } -CefSchemeRegistrarImpl::CefSchemeRegistrarImpl() - : supported_thread_id_(base::PlatformThread::CurrentId()) { +CefSchemeRegistrarImpl::CefSchemeRegistrarImpl() { } bool CefSchemeRegistrarImpl::AddCustomScheme( @@ -35,9 +34,6 @@ bool CefSchemeRegistrarImpl::AddCustomScheme( bool is_display_isolated, bool is_secure, bool is_cors_enabled) { - if (!VerifyContext()) - return false; - const std::string& scheme = base::ToLowerASCII(scheme_name.ToString()); if (scheme::IsInternalHandledScheme(scheme) || registered_schemes_.find(scheme) != registered_schemes_.end()) { @@ -68,30 +64,8 @@ bool CefSchemeRegistrarImpl::AddCustomScheme( void CefSchemeRegistrarImpl::GetSchemes( content::ContentClient::Schemes* schemes) { - if (!VerifyContext()) - return; - AppendArray(schemes_.standard_schemes, &schemes->standard_schemes); AppendArray(schemes_.local_schemes, &schemes->local_schemes); AppendArray(schemes_.secure_schemes, &schemes->secure_schemes); AppendArray(schemes_.cors_enabled_schemes, &schemes->cors_enabled_schemes); } - -bool CefSchemeRegistrarImpl::VerifyRefCount() { - return HasOneRef(); -} - -void CefSchemeRegistrarImpl::Detach() { - if (VerifyContext()) - supported_thread_id_ = base::kInvalidThreadId; -} - -bool CefSchemeRegistrarImpl::VerifyContext() { - if (base::PlatformThread::CurrentId() != supported_thread_id_) { - // This object should only be accessed from the thread that created it. - NOTREACHED(); - return false; - } - - return true; -} diff --git a/libcef/common/scheme_registrar_impl.h b/libcef/common/scheme_registrar_impl.h index d009bc7ac..1567df442 100644 --- a/libcef/common/scheme_registrar_impl.h +++ b/libcef/common/scheme_registrar_impl.h @@ -11,7 +11,6 @@ #include "include/cef_scheme.h" -#include "base/threading/platform_thread.h" #include "content/public/common/content_client.h" class CefSchemeRegistrarImpl : public CefSchemeRegistrar { @@ -28,22 +27,13 @@ class CefSchemeRegistrarImpl : public CefSchemeRegistrar { void GetSchemes(content::ContentClient::Schemes* schemes); - // Verify that only a single reference exists to all CefSchemeRegistrarImpl - // objects. - bool VerifyRefCount(); - - void Detach(); - private: // Verify that the object is being accessed from the correct thread. bool VerifyContext(); - base::PlatformThreadId supported_thread_id_; - content::ContentClient::Schemes schemes_; std::set registered_schemes_; - IMPLEMENT_REFCOUNTING(CefSchemeRegistrarImpl); DISALLOW_COPY_AND_ASSIGN(CefSchemeRegistrarImpl); }; diff --git a/libcef/common/test/translator_test_impl.cc b/libcef/common/test/translator_test_impl.cc index d82411f90..23ed616be 100644 --- a/libcef/common/test/translator_test_impl.cc +++ b/libcef/common/test/translator_test_impl.cc @@ -4,9 +4,10 @@ #include "include/test/cef_translator_test.h" -class CefTranslatorTestObjectImpl : public CefTranslatorTestObject { +class CefTranslatorTestRefPtrLibraryImpl : + public CefTranslatorTestRefPtrLibrary { public: - explicit CefTranslatorTestObjectImpl(int value) + explicit CefTranslatorTestRefPtrLibraryImpl(int value) : value_(value) { } @@ -22,18 +23,20 @@ class CefTranslatorTestObjectImpl : public CefTranslatorTestObject { int value_; private: - DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestObjectImpl); - IMPLEMENT_REFCOUNTING(CefTranslatorTestObjectImpl); + DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestRefPtrLibraryImpl); + IMPLEMENT_REFCOUNTING(CefTranslatorTestRefPtrLibraryImpl); }; // static -CefRefPtr CefTranslatorTestObject::Create(int value) { - return new CefTranslatorTestObjectImpl(value); +CefRefPtr +CefTranslatorTestRefPtrLibrary::Create(int value) { + return new CefTranslatorTestRefPtrLibraryImpl(value); } -class CefTranslatorTestObjectChildImpl : public CefTranslatorTestObjectChild { +class CefTranslatorTestRefPtrLibraryChildImpl : + public CefTranslatorTestRefPtrLibraryChild { public: - CefTranslatorTestObjectChildImpl(int value, int other_value) + CefTranslatorTestRefPtrLibraryChildImpl(int value, int other_value) : value_(value), other_value_(other_value) { } @@ -59,21 +62,22 @@ class CefTranslatorTestObjectChildImpl : public CefTranslatorTestObjectChild { int other_value_; private: - DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestObjectChildImpl); - IMPLEMENT_REFCOUNTING(CefTranslatorTestObjectChildImpl); + DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestRefPtrLibraryChildImpl); + IMPLEMENT_REFCOUNTING(CefTranslatorTestRefPtrLibraryChildImpl); }; // static -CefRefPtr CefTranslatorTestObjectChild::Create( +CefRefPtr +CefTranslatorTestRefPtrLibraryChild::Create( int value, int other_value) { - return new CefTranslatorTestObjectChildImpl(value, other_value); + return new CefTranslatorTestRefPtrLibraryChildImpl(value, other_value); } -class CefTranslatorTestObjectChildChildImpl : - public CefTranslatorTestObjectChildChild { +class CefTranslatorTestRefPtrLibraryChildChildImpl : + public CefTranslatorTestRefPtrLibraryChildChild { public: - CefTranslatorTestObjectChildChildImpl(int value, + CefTranslatorTestRefPtrLibraryChildChildImpl(int value, int other_value, int other_other_value) : value_(value), @@ -111,20 +115,147 @@ class CefTranslatorTestObjectChildChildImpl : int other_other_value_; private: - DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestObjectChildChildImpl); - IMPLEMENT_REFCOUNTING(CefTranslatorTestObjectChildChildImpl); + DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestRefPtrLibraryChildChildImpl); + IMPLEMENT_REFCOUNTING(CefTranslatorTestRefPtrLibraryChildChildImpl); }; // static -CefRefPtr -CefTranslatorTestObjectChildChild::Create( +CefRefPtr +CefTranslatorTestRefPtrLibraryChildChild::Create( int value, int other_value, int other_other_value) { - return new CefTranslatorTestObjectChildChildImpl(value, other_value, - other_other_value); + return new CefTranslatorTestRefPtrLibraryChildChildImpl(value, other_value, + other_other_value); } + +class CefTranslatorTestScopedLibraryImpl : + public CefTranslatorTestScopedLibrary { + public: + explicit CefTranslatorTestScopedLibraryImpl(int value) + : value_(value) { + } + + int GetValue() override { + return value_; + } + + void SetValue(int value) override { + value_ = value; + } + + protected: + int value_; + + private: + DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestScopedLibraryImpl); +}; + +// static +CefOwnPtr +CefTranslatorTestScopedLibrary::Create(int value) { + return CefOwnPtr( + new CefTranslatorTestScopedLibraryImpl(value)); +} + +class CefTranslatorTestScopedLibraryChildImpl : + public CefTranslatorTestScopedLibraryChild { + public: + CefTranslatorTestScopedLibraryChildImpl(int value, int other_value) + : value_(value), + other_value_(other_value) { + } + + int GetValue() override { + return value_; + } + + void SetValue(int value) override { + value_ = value; + } + + int GetOtherValue() override { + return other_value_; + } + + void SetOtherValue(int value) override { + other_value_ = value; + } + + protected: + int value_; + int other_value_; + + private: + DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestScopedLibraryChildImpl); +}; + +// static +CefOwnPtr +CefTranslatorTestScopedLibraryChild::Create( + int value, + int other_value) { + return CefOwnPtr( + new CefTranslatorTestScopedLibraryChildImpl(value, other_value)); +} + +class CefTranslatorTestScopedLibraryChildChildImpl : + public CefTranslatorTestScopedLibraryChildChild { + public: + CefTranslatorTestScopedLibraryChildChildImpl(int value, + int other_value, + int other_other_value) + : value_(value), + other_value_(other_value), + other_other_value_(other_other_value) { + } + + int GetValue() override { + return value_; + } + + void SetValue(int value) override { + value_ = value; + } + + int GetOtherValue() override { + return other_value_; + } + + void SetOtherValue(int value) override { + other_value_ = value; + } + + int GetOtherOtherValue() override { + return other_other_value_; + } + + void SetOtherOtherValue(int value) override { + other_other_value_ = value; + } + + protected: + int value_; + int other_value_; + int other_other_value_; + + private: + DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestScopedLibraryChildChildImpl); +}; + +// static +CefOwnPtr +CefTranslatorTestScopedLibraryChildChild::Create( + int value, + int other_value, + int other_other_value) { + return CefOwnPtr( + new CefTranslatorTestScopedLibraryChildChildImpl(value, other_value, + other_other_value)); +} + + class CefTranslatorTestImpl : public CefTranslatorTest { public: CefTranslatorTestImpl() { @@ -338,91 +469,95 @@ class CefTranslatorTestImpl : public CefTranslatorTest { } - // LIBRARY-SIDE OBJECT VALUES + // LIBRARY-SIDE REFPTR VALUES - CefRefPtr GetObject(int val) override { - return new CefTranslatorTestObjectChildImpl(val, 0); + CefRefPtr GetRefPtrLibrary(int val) override { + return new CefTranslatorTestRefPtrLibraryChildImpl(val, 0); } - int SetObject(CefRefPtr val) override { + int SetRefPtrLibrary(CefRefPtr val) override { return val->GetValue(); } - CefRefPtr SetObjectAndReturn( - CefRefPtr val) override { + CefRefPtr SetRefPtrLibraryAndReturn( + CefRefPtr val) override { return val; } - int SetChildObject(CefRefPtr val) override { + int SetChildRefPtrLibrary( + CefRefPtr val) override { return val->GetValue(); } - CefRefPtr SetChildObjectAndReturnParent( - CefRefPtr val) override { + CefRefPtr + SetChildRefPtrLibraryAndReturnParent( + CefRefPtr val) override { return val; } - // LIBRARY-SIDE OBJECT LIST VALUES + // LIBRARY-SIDE REFPTR LIST VALUES - bool SetObjectList( - const std::vector >& val, + bool SetRefPtrLibraryList( + const std::vector >& val, int val1, int val2) override { if (val.size() != 2U) return false; return val[0]->GetValue() == val1 && val[1]->GetValue() == val2; } - bool GetObjectListByRef(ObjectList& val, int val1, int val2) override { - if (val.size() != GetObjectListSize()) + bool GetRefPtrLibraryListByRef(RefPtrLibraryList& val, int val1, + int val2) override { + if (val.size() != GetRefPtrLibraryListSize()) return false; val.clear(); - val.push_back(new CefTranslatorTestObjectChildImpl(val1, 0)); - val.push_back(new CefTranslatorTestObjectImpl(val2)); + val.push_back(new CefTranslatorTestRefPtrLibraryChildImpl(val1, 0)); + val.push_back(new CefTranslatorTestRefPtrLibraryImpl(val2)); return true; } - size_t GetObjectListSize() override { + size_t GetRefPtrLibraryListSize() override { return 2U; } - // CLIENT-SIDE OBJECT VALUES + // CLIENT-SIDE REFPTR VALUES - int SetHandler(CefRefPtr val) override { + int SetRefPtrClient(CefRefPtr val) override { return val->GetValue(); } - CefRefPtr SetHandlerAndReturn( - CefRefPtr val) override { + CefRefPtr SetRefPtrClientAndReturn( + CefRefPtr val) override { return val; } - int SetChildHandler(CefRefPtr val) override { + int SetChildRefPtrClient( + CefRefPtr val) override { return val->GetValue(); } - CefRefPtr SetChildHandlerAndReturnParent( - CefRefPtr val) override { + CefRefPtr SetChildRefPtrClientAndReturnParent( + CefRefPtr val) override { return val; } - // CLIENT-SIDE OBJECT LIST VALUES + // CLIENT-SIDE REFPTR LIST VALUES - bool SetHandlerList( - const std::vector >& val, + bool SetRefPtrClientList( + const std::vector >& val, int val1, int val2) override { if (val.size() != 2U) return false; return val[0]->GetValue() == val1 && val[1]->GetValue() == val2; } - bool GetHandlerListByRef( - HandlerList& val, - CefRefPtr val1, - CefRefPtr val2) override { - if (val.size() != GetHandlerListSize()) + bool GetRefPtrClientListByRef( + RefPtrClientList& val, + CefRefPtr val1, + CefRefPtr val2) override { + if (val.size() != GetRefPtrClientListSize()) return false; val.clear(); val.push_back(val1); @@ -430,10 +565,106 @@ class CefTranslatorTestImpl : public CefTranslatorTest { return true; } - size_t GetHandlerListSize() override { + size_t GetRefPtrClientListSize() override { return 2U; } + + // LIBRARY-SIDE OWNPTR VALUES + + CefOwnPtr GetOwnPtrLibrary(int val) override { + return CefOwnPtr( + new CefTranslatorTestScopedLibraryChildImpl(val, 0)); + } + + int SetOwnPtrLibrary(CefOwnPtr val) override { + return val->GetValue(); + } + + CefOwnPtr SetOwnPtrLibraryAndReturn( + CefOwnPtr val) override { + return val; + } + + int SetChildOwnPtrLibrary( + CefOwnPtr val) override { + return val->GetValue(); + } + + CefOwnPtr + SetChildOwnPtrLibraryAndReturnParent( + CefOwnPtr val) override { + return CefOwnPtr(val.release()); + } + + + // CLIENT-SIDE OWNPTR VALUES + + int SetOwnPtrClient(CefOwnPtr val) override { + return val->GetValue(); + } + + CefOwnPtr SetOwnPtrClientAndReturn( + CefOwnPtr val) override { + return val; + } + + int SetChildOwnPtrClient( + CefOwnPtr val) override { + return val->GetValue(); + } + + CefOwnPtr SetChildOwnPtrClientAndReturnParent( + CefOwnPtr val) override { + return CefOwnPtr(val.release()); + } + + + // LIBRARY-SIDE RAWPTR VALUES + + int SetRawPtrLibrary(CefRawPtr val) override { + return val->GetValue(); + } + + int SetChildRawPtrLibrary( + CefRawPtr val) override { + return val->GetValue(); + } + + + // LIBRARY-SIDE RAWPTR LIST VALUES + + bool SetRawPtrLibraryList( + const std::vector >& val, + int val1, int val2) override { + if (val.size() != 2U) + return false; + return val[0]->GetValue() == val1 && val[1]->GetValue() == val2; + } + + + // CLIENT-SIDE RAWPTR VALUES + + int SetRawPtrClient(CefRawPtr val) override { + return val->GetValue(); + } + + int SetChildRawPtrClient( + CefRawPtr val) override { + return val->GetValue(); + } + + + // CLIENT-SIDE RAWPTR LIST VALUES + + bool SetRawPtrClientList( + const std::vector >& val, + int val1, int val2) override { + if (val.size() != 2U) + return false; + return val[0]->GetValue() == val1 && val[1]->GetValue() == val2; + } + private: IMPLEMENT_REFCOUNTING(CefTranslatorTestImpl); DISALLOW_COPY_AND_ASSIGN(CefTranslatorTestImpl); diff --git a/libcef_dll/cpptoc/app_cpptoc.cc b/libcef_dll/cpptoc/app_cpptoc.cc index aa29a7342..0963510d1 100644 --- a/libcef_dll/cpptoc/app_cpptoc.cc +++ b/libcef_dll/cpptoc/app_cpptoc.cc @@ -49,14 +49,18 @@ void CEF_CALLBACK app_on_register_custom_schemes(struct _cef_app_t* self, DCHECK(self); if (!self) return; - // Verify param: registrar; type: refptr_diff + // Verify param: registrar; type: rawptr_diff DCHECK(registrar); if (!registrar) return; + // Translate param: registrar; type: rawptr_diff + CefOwnPtr registrarPtr(CefSchemeRegistrarCToCpp::Wrap( + registrar)); + // Execute CefAppCppToC::Get(self)->OnRegisterCustomSchemes( - CefSchemeRegistrarCToCpp::Wrap(registrar)); + registrarPtr.get()); } struct _cef_resource_bundle_handler_t* CEF_CALLBACK app_get_resource_bundle_handler( diff --git a/libcef_dll/cpptoc/base_scoped_cpptoc.cc b/libcef_dll/cpptoc/base_scoped_cpptoc.cc new file mode 100644 index 000000000..7562b04ff --- /dev/null +++ b/libcef_dll/cpptoc/base_scoped_cpptoc.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2017 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 "libcef_dll/cpptoc/base_scoped_cpptoc.h" + +CefBaseScopedCppToC::CefBaseScopedCppToC() { +} + +template<> CefOwnPtr +CefCppToCScoped:: + UnwrapDerivedOwn(CefWrapperType type, cef_base_scoped_t* s) { + NOTREACHED(); + return CefOwnPtr(); +} + +template<> CefRawPtr +CefCppToCScoped:: + UnwrapDerivedRaw(CefWrapperType type, cef_base_scoped_t* s) { + NOTREACHED(); + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToCScoped::kWrapperType = WT_BASE; diff --git a/libcef_dll/cpptoc/base_scoped_cpptoc.h b/libcef_dll/cpptoc/base_scoped_cpptoc.h new file mode 100644 index 000000000..4d72763ee --- /dev/null +++ b/libcef_dll/cpptoc/base_scoped_cpptoc.h @@ -0,0 +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. + +#ifndef CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +// Wrap a C++ class with a C structure. +class CefBaseScopedCppToC + : public CefCppToCScoped { + public: + CefBaseScopedCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/cpptoc_scoped.h b/libcef_dll/cpptoc/cpptoc_scoped.h new file mode 100644 index 000000000..4230ef77f --- /dev/null +++ b/libcef_dll/cpptoc/cpptoc_scoped.h @@ -0,0 +1,241 @@ +// Copyright (c) 2017 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 CEF_LIBCEF_DLL_CPPTOC_CPPTOC_SCOPED_H_ +#define CEF_LIBCEF_DLL_CPPTOC_CPPTOC_SCOPED_H_ +#pragma once + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/ptr_util.h" +#include "libcef_dll/wrapper_types.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 CefCppToCScoped : public CefBaseScoped { + public: + // Create a new wrapper instance and associated structure reference for + // passing an object instance the other side. The wrapper object will be + // deleted when |del| is called on the associated structure. The wrapped + // object will be deleted when the wrapper object is deleted. For example: + // + // void MyMethod(CefOwnPtr obj) { + // my_method(MyTypeCppToC::WrapOwn(obj)); + // } + // + // void my_method(my_type_t* struct) { + // // Delete the MyTypeCppToC wrapper and the owned MyType object. + // struct->del(struct); + // } + static StructName* WrapOwn(CefOwnPtr c) { + if (!c) + return NULL; + + // Wrap our object with the CefCppToC class. + ClassName* wrapper = new ClassName(); + wrapper->Initialize(c.release(), true); + + // Return the structure pointer that can now be passed to the other side. + return wrapper->GetStruct(); + } + + // Create a new wrapper instance and associated structure reference for + // passing an object instance to the other side. The wrapper object is owned + // by the caller. The wrapped object is unowned and must outlive the wrapper. + // For example: + // + // void MyMethod(MyType* obj) { + // CefOwnPtr MyTypeWrapper = MyTypeCppToC::WrapRaw(obj); + // my_method(MyTypeWrapper->GetStruct()); + // // MyTypeWrapper is deleted when MyMethod() goes out of scope. + // } + // + // void my_method(my_type_t* struct) { + // // Access |struct| here but you can't delete it. + // } + static CefOwnPtr WrapRaw(CefRawPtr c) { + if (!c) + return CefOwnPtr(); + + // Wrap our object with the CefCppToC class. + ClassName* wrapper = new ClassName(); + wrapper->Initialize(c, false); + + // Return the owned wrapper object. + return CefOwnPtr(wrapper); + } + + // Retrieve the underlying object instance for a structure reference passed + // back from the other side. The caller takes ownership of the object. For + // example: + // + // void my_method(my_type_t* struct) { + // CefOwnPtr MyTypePtr = MyTypeCppToC::UnwrapOwn(struct); + // // |struct| has been deleted and should no longer be accessed. + // } + static CefOwnPtr UnwrapOwn(StructName* s) { + if (!s) + return CefOwnPtr(); + + // Cast our structure to the wrapper structure type. + WrapperStruct* wrapperStruct = GetWrapperStruct(s); + + // If the type does not match this object then we need to unwrap as the + // derived type. + if (wrapperStruct->type_ != kWrapperType) + return UnwrapDerivedOwn(wrapperStruct->type_, s); + + // We should own the underlying object currently. + DCHECK(wrapperStruct->wrapper_->owned_); + DCHECK(wrapperStruct->object_); + + // We're giving up ownership of the underlying object. Clear the pointer so + // it doesn't get deleted. + BaseName* object = wrapperStruct->object_; + wrapperStruct->object_ = NULL; + + delete wrapperStruct->wrapper_; + + // Return the underlying object instance. + return CefOwnPtr(object); + } + + // Retrieve the underlying object instance for a structure reference passed + // back from the other side. Ownership does not change. For example: + // + // void my_method(my_type_t* struct) { + // CefRawPtr MyTypePtr = MyTypeCppToC::UnwrapRaw(struct); + // // |struct| is still valid. + // } + static CefRawPtr UnwrapRaw(StructName* s) { + if (!s) + return NULL; + + // Cast our structure to the wrapper structure type. + WrapperStruct* wrapperStruct = GetWrapperStruct(s); + + // If the type does not match this object then we need to unwrap as the + // derived type. + if (wrapperStruct->type_ != kWrapperType) + return UnwrapDerivedRaw(wrapperStruct->type_, s); + + // Return the underlying object instance. + return wrapperStruct->object_; + } + + // Retrieve the same side wrapper associated with the structure. Ownership + // does not change. + static ClassName* GetWrapper(StructName* s) { + DCHECK(s); + WrapperStruct* wrapperStruct = GetWrapperStruct(s); + // Verify that the wrapper offset was calculated correctly. + DCHECK_EQ(kWrapperType, wrapperStruct->type_); + return static_cast(wrapperStruct->wrapper_); + } + + // Retrieve the underlying object instance from our own structure reference + // when the reference is passed as the required first parameter of a C API + // function call. Ownership of the object does not change. + static BaseName* Get(StructName* s) { + DCHECK(s); + WrapperStruct* wrapperStruct = GetWrapperStruct(s); + // Verify that the wrapper offset was calculated correctly. + DCHECK_EQ(kWrapperType, wrapperStruct->type_); + return wrapperStruct->object_; + } + + // 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 &wrapper_struct_.struct_; } + +#if DCHECK_IS_ON() + // Simple tracking of allocated objects. + static base::AtomicRefCount DebugObjCt; // NOLINT(runtime/int) +#endif + + protected: + CefCppToCScoped() { + wrapper_struct_.type_ = kWrapperType; + wrapper_struct_.wrapper_ = this; + memset(GetStruct(), 0, sizeof(StructName)); + +#if DCHECK_IS_ON() + base::AtomicRefCountInc(&DebugObjCt); +#endif + } + + virtual ~CefCppToCScoped() { + // Only delete the underlying object if we own it. + if (owned_ && wrapper_struct_.object_) + delete wrapper_struct_.object_; + +#if DCHECK_IS_ON() + base::AtomicRefCountDec(&DebugObjCt); +#endif + } + + private: + // Used to associate this wrapper object, the underlying object instance and + // the structure that will be passed to the other side. + struct WrapperStruct { + CefWrapperType type_; + BaseName* object_; + CefCppToCScoped* wrapper_; + StructName struct_; + }; + + void Initialize(BaseName* obj, bool owned) { + wrapper_struct_.object_ = obj; + owned_ = owned; + + cef_base_scoped_t* base = reinterpret_cast(GetStruct()); + base->size = sizeof(StructName); + if (owned) + base->del = struct_del; + } + + static WrapperStruct* GetWrapperStruct(StructName* s) { + // Offset using the WrapperStruct size instead of individual member sizes + // to avoid problems due to platform/compiler differences in structure + // padding. + return reinterpret_cast( + reinterpret_cast(s) - + (sizeof(WrapperStruct) - sizeof(StructName))); + } + + // Unwrap as the derived type. + static CefOwnPtr UnwrapDerivedOwn(CefWrapperType type, + StructName* s); + static CefRawPtr UnwrapDerivedRaw(CefWrapperType type, + StructName* s); + + static void CEF_CALLBACK struct_del(cef_base_scoped_t* base) { + DCHECK(base); + if (!base) + return; + + WrapperStruct* wrapperStruct = + GetWrapperStruct(reinterpret_cast(base)); + // Verify that the wrapper offset was calculated correctly. + DCHECK_EQ(kWrapperType, wrapperStruct->type_); + + // Should only be deleting wrappers that own the underlying object. + DCHECK(wrapperStruct->wrapper_->owned_); + delete wrapperStruct->wrapper_; + } + + WrapperStruct wrapper_struct_; + bool owned_; + + static CefWrapperType kWrapperType; + + DISALLOW_COPY_AND_ASSIGN(CefCppToCScoped); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_CPPTOC_SCOPED_H_ diff --git a/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc b/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc index 50e29de5d..95f68042c 100644 --- a/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc +++ b/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc @@ -53,18 +53,25 @@ CefSchemeRegistrarCppToC::CefSchemeRegistrarCppToC() { GetStruct()->add_custom_scheme = scheme_registrar_add_custom_scheme; } -template<> CefRefPtr CefCppToC::UnwrapDerived( +template<> CefOwnPtr CefCppToCScoped::UnwrapDerivedOwn( + CefWrapperType type, cef_scheme_registrar_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return CefOwnPtr(); +} + +template<> CefRawPtr CefCppToCScoped::UnwrapDerivedRaw( CefWrapperType type, cef_scheme_registrar_t* s) { NOTREACHED() << "Unexpected class type: " << type; return NULL; } #if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; #endif -template<> CefWrapperType CefCppToC CefWrapperType CefCppToCScoped::kWrapperType = WT_SCHEME_REGISTRAR; diff --git a/libcef_dll/cpptoc/scheme_registrar_cpptoc.h b/libcef_dll/cpptoc/scheme_registrar_cpptoc.h index 44daaa32a..857293142 100644 --- a/libcef_dll/cpptoc/scheme_registrar_cpptoc.h +++ b/libcef_dll/cpptoc/scheme_registrar_cpptoc.h @@ -20,12 +20,12 @@ #include "include/cef_scheme.h" #include "include/capi/cef_scheme_capi.h" -#include "libcef_dll/cpptoc/cpptoc.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" // Wrap a C++ class with a C structure. // This class may be instantiated and accessed DLL-side only. class CefSchemeRegistrarCppToC - : public CefCppToC { public: CefSchemeRegistrarCppToC(); diff --git a/libcef_dll/cpptoc/test/translator_test_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_cpptoc.cc index a8807cf57..558021dd7 100644 --- a/libcef_dll/cpptoc/test/translator_test_cpptoc.cc +++ b/libcef_dll/cpptoc/test/translator_test_cpptoc.cc @@ -12,10 +12,14 @@ #include #include "libcef_dll/cpptoc/test/translator_test_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_object_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h" -#include "libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -653,7 +657,7 @@ size_t CEF_CALLBACK translator_test_get_point_list_size( return _retval; } -struct _cef_translator_test_object_t* CEF_CALLBACK translator_test_get_object( +struct _cef_translator_test_ref_ptr_library_t* CEF_CALLBACK translator_test_get_ref_ptr_library( struct _cef_translator_test_t* self, int val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -662,16 +666,17 @@ struct _cef_translator_test_object_t* CEF_CALLBACK translator_test_get_object( return NULL; // Execute - CefRefPtr _retval = CefTranslatorTestCppToC::Get( - self)->GetObject( + CefRefPtr _retval = + CefTranslatorTestCppToC::Get(self)->GetRefPtrLibrary( val); // Return type: refptr_same - return CefTranslatorTestObjectCppToC::Wrap(_retval); + return CefTranslatorTestRefPtrLibraryCppToC::Wrap(_retval); } -int CEF_CALLBACK translator_test_set_object(struct _cef_translator_test_t* self, - struct _cef_translator_test_object_t* val) { +int CEF_CALLBACK translator_test_set_ref_ptr_library( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -683,16 +688,16 @@ int CEF_CALLBACK translator_test_set_object(struct _cef_translator_test_t* self, return 0; // Execute - int _retval = CefTranslatorTestCppToC::Get(self)->SetObject( - CefTranslatorTestObjectCppToC::Unwrap(val)); + int _retval = CefTranslatorTestCppToC::Get(self)->SetRefPtrLibrary( + CefTranslatorTestRefPtrLibraryCppToC::Unwrap(val)); // Return type: simple return _retval; } -struct _cef_translator_test_object_t* CEF_CALLBACK translator_test_set_object_and_return( +struct _cef_translator_test_ref_ptr_library_t* CEF_CALLBACK translator_test_set_ref_ptr_library_and_return( struct _cef_translator_test_t* self, - struct _cef_translator_test_object_t* val) { + struct _cef_translator_test_ref_ptr_library_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -704,17 +709,17 @@ struct _cef_translator_test_object_t* CEF_CALLBACK translator_test_set_object_an return NULL; // Execute - CefRefPtr _retval = CefTranslatorTestCppToC::Get( - self)->SetObjectAndReturn( - CefTranslatorTestObjectCppToC::Unwrap(val)); + CefRefPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetRefPtrLibraryAndReturn( + CefTranslatorTestRefPtrLibraryCppToC::Unwrap(val)); // Return type: refptr_same - return CefTranslatorTestObjectCppToC::Wrap(_retval); + return CefTranslatorTestRefPtrLibraryCppToC::Wrap(_retval); } -int CEF_CALLBACK translator_test_set_child_object( +int CEF_CALLBACK translator_test_set_child_ref_ptr_library( struct _cef_translator_test_t* self, - struct _cef_translator_test_object_child_t* val) { + struct _cef_translator_test_ref_ptr_library_child_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -726,16 +731,16 @@ int CEF_CALLBACK translator_test_set_child_object( return 0; // Execute - int _retval = CefTranslatorTestCppToC::Get(self)->SetChildObject( - CefTranslatorTestObjectChildCppToC::Unwrap(val)); + int _retval = CefTranslatorTestCppToC::Get(self)->SetChildRefPtrLibrary( + CefTranslatorTestRefPtrLibraryChildCppToC::Unwrap(val)); // Return type: simple return _retval; } -struct _cef_translator_test_object_t* CEF_CALLBACK translator_test_set_child_object_and_return_parent( +struct _cef_translator_test_ref_ptr_library_t* CEF_CALLBACK translator_test_set_child_ref_ptr_library_and_return_parent( struct _cef_translator_test_t* self, - struct _cef_translator_test_object_child_t* val) { + struct _cef_translator_test_ref_ptr_library_child_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -747,17 +752,18 @@ struct _cef_translator_test_object_t* CEF_CALLBACK translator_test_set_child_obj return NULL; // Execute - CefRefPtr _retval = CefTranslatorTestCppToC::Get( - self)->SetChildObjectAndReturnParent( - CefTranslatorTestObjectChildCppToC::Unwrap(val)); + CefRefPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetChildRefPtrLibraryAndReturnParent( + CefTranslatorTestRefPtrLibraryChildCppToC::Unwrap(val)); // Return type: refptr_same - return CefTranslatorTestObjectCppToC::Wrap(_retval); + return CefTranslatorTestRefPtrLibraryCppToC::Wrap(_retval); } -int CEF_CALLBACK translator_test_set_object_list( +int CEF_CALLBACK translator_test_set_ref_ptr_library_list( struct _cef_translator_test_t* self, size_t valCount, - struct _cef_translator_test_object_t* const* val, int val1, int val2) { + struct _cef_translator_test_ref_ptr_library_t* const* val, int val1, + int val2) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -769,17 +775,17 @@ int CEF_CALLBACK translator_test_set_object_list( return 0; // Translate param: val; type: refptr_vec_same_byref_const - std::vector > valList; + std::vector > valList; if (valCount > 0) { for (size_t i = 0; i < valCount; ++i) { - CefRefPtr valVal = - CefTranslatorTestObjectCppToC::Unwrap(val[i]); + CefRefPtr valVal = + CefTranslatorTestRefPtrLibraryCppToC::Unwrap(val[i]); valList.push_back(valVal); } } // Execute - bool _retval = CefTranslatorTestCppToC::Get(self)->SetObjectList( + bool _retval = CefTranslatorTestCppToC::Get(self)->SetRefPtrLibraryList( valList, val1, val2); @@ -788,9 +794,9 @@ int CEF_CALLBACK translator_test_set_object_list( return _retval; } -int CEF_CALLBACK translator_test_get_object_list_by_ref( +int CEF_CALLBACK translator_test_get_ref_ptr_library_list_by_ref( struct _cef_translator_test_t* self, size_t* valCount, - struct _cef_translator_test_object_t** val, int val1, int val2) { + struct _cef_translator_test_ref_ptr_library_t** val, int val1, int val2) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -802,15 +808,15 @@ int CEF_CALLBACK translator_test_get_object_list_by_ref( return 0; // Translate param: val; type: refptr_vec_same_byref - std::vector > valList; + std::vector > valList; if (valCount && *valCount > 0 && val) { for (size_t i = 0; i < *valCount; ++i) { - valList.push_back(CefTranslatorTestObjectCppToC::Unwrap(val[i])); + valList.push_back(CefTranslatorTestRefPtrLibraryCppToC::Unwrap(val[i])); } } // Execute - bool _retval = CefTranslatorTestCppToC::Get(self)->GetObjectListByRef( + bool _retval = CefTranslatorTestCppToC::Get(self)->GetRefPtrLibraryListByRef( valList, val1, val2); @@ -820,7 +826,7 @@ int CEF_CALLBACK translator_test_get_object_list_by_ref( *valCount = std::min(valList.size(), *valCount); if (*valCount > 0) { for (size_t i = 0; i < *valCount; ++i) { - val[i] = CefTranslatorTestObjectCppToC::Wrap(valList[i]); + val[i] = CefTranslatorTestRefPtrLibraryCppToC::Wrap(valList[i]); } } } @@ -829,7 +835,7 @@ int CEF_CALLBACK translator_test_get_object_list_by_ref( return _retval; } -size_t CEF_CALLBACK translator_test_get_object_list_size( +size_t CEF_CALLBACK translator_test_get_ref_ptr_library_list_size( struct _cef_translator_test_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -838,15 +844,16 @@ size_t CEF_CALLBACK translator_test_get_object_list_size( return 0; // Execute - size_t _retval = CefTranslatorTestCppToC::Get(self)->GetObjectListSize(); + size_t _retval = CefTranslatorTestCppToC::Get(self)->GetRefPtrLibraryListSize( + ); // Return type: simple return _retval; } -int CEF_CALLBACK translator_test_set_handler( +int CEF_CALLBACK translator_test_set_ref_ptr_client( struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_t* val) { + struct _cef_translator_test_ref_ptr_client_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -858,16 +865,16 @@ int CEF_CALLBACK translator_test_set_handler( return 0; // Execute - int _retval = CefTranslatorTestCppToC::Get(self)->SetHandler( - CefTranslatorTestHandlerCToCpp::Wrap(val)); + int _retval = CefTranslatorTestCppToC::Get(self)->SetRefPtrClient( + CefTranslatorTestRefPtrClientCToCpp::Wrap(val)); // Return type: simple return _retval; } -struct _cef_translator_test_handler_t* CEF_CALLBACK translator_test_set_handler_and_return( +struct _cef_translator_test_ref_ptr_client_t* CEF_CALLBACK translator_test_set_ref_ptr_client_and_return( struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_t* val) { + struct _cef_translator_test_ref_ptr_client_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -879,17 +886,17 @@ struct _cef_translator_test_handler_t* CEF_CALLBACK translator_test_set_handler_ return NULL; // Execute - CefRefPtr _retval = CefTranslatorTestCppToC::Get( - self)->SetHandlerAndReturn( - CefTranslatorTestHandlerCToCpp::Wrap(val)); + CefRefPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetRefPtrClientAndReturn( + CefTranslatorTestRefPtrClientCToCpp::Wrap(val)); // Return type: refptr_diff - return CefTranslatorTestHandlerCToCpp::Unwrap(_retval); + return CefTranslatorTestRefPtrClientCToCpp::Unwrap(_retval); } -int CEF_CALLBACK translator_test_set_child_handler( +int CEF_CALLBACK translator_test_set_child_ref_ptr_client( struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_child_t* val) { + struct _cef_translator_test_ref_ptr_client_child_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -901,16 +908,16 @@ int CEF_CALLBACK translator_test_set_child_handler( return 0; // Execute - int _retval = CefTranslatorTestCppToC::Get(self)->SetChildHandler( - CefTranslatorTestHandlerChildCToCpp::Wrap(val)); + int _retval = CefTranslatorTestCppToC::Get(self)->SetChildRefPtrClient( + CefTranslatorTestRefPtrClientChildCToCpp::Wrap(val)); // Return type: simple return _retval; } -struct _cef_translator_test_handler_t* CEF_CALLBACK translator_test_set_child_handler_and_return_parent( +struct _cef_translator_test_ref_ptr_client_t* CEF_CALLBACK translator_test_set_child_ref_ptr_client_and_return_parent( struct _cef_translator_test_t* self, - struct _cef_translator_test_handler_child_t* val) { + struct _cef_translator_test_ref_ptr_client_child_t* val) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -922,17 +929,18 @@ struct _cef_translator_test_handler_t* CEF_CALLBACK translator_test_set_child_ha return NULL; // Execute - CefRefPtr _retval = CefTranslatorTestCppToC::Get( - self)->SetChildHandlerAndReturnParent( - CefTranslatorTestHandlerChildCToCpp::Wrap(val)); + CefRefPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetChildRefPtrClientAndReturnParent( + CefTranslatorTestRefPtrClientChildCToCpp::Wrap(val)); // Return type: refptr_diff - return CefTranslatorTestHandlerCToCpp::Unwrap(_retval); + return CefTranslatorTestRefPtrClientCToCpp::Unwrap(_retval); } -int CEF_CALLBACK translator_test_set_handler_list( +int CEF_CALLBACK translator_test_set_ref_ptr_client_list( struct _cef_translator_test_t* self, size_t valCount, - struct _cef_translator_test_handler_t* const* val, int val1, int val2) { + struct _cef_translator_test_ref_ptr_client_t* const* val, int val1, + int val2) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -944,17 +952,17 @@ int CEF_CALLBACK translator_test_set_handler_list( return 0; // Translate param: val; type: refptr_vec_diff_byref_const - std::vector > valList; + std::vector > valList; if (valCount > 0) { for (size_t i = 0; i < valCount; ++i) { - CefRefPtr valVal = - CefTranslatorTestHandlerCToCpp::Wrap(val[i]); + CefRefPtr valVal = + CefTranslatorTestRefPtrClientCToCpp::Wrap(val[i]); valList.push_back(valVal); } } // Execute - bool _retval = CefTranslatorTestCppToC::Get(self)->SetHandlerList( + bool _retval = CefTranslatorTestCppToC::Get(self)->SetRefPtrClientList( valList, val1, val2); @@ -963,11 +971,11 @@ int CEF_CALLBACK translator_test_set_handler_list( return _retval; } -int CEF_CALLBACK translator_test_get_handler_list_by_ref( +int CEF_CALLBACK translator_test_get_ref_ptr_client_list_by_ref( struct _cef_translator_test_t* self, size_t* valCount, - struct _cef_translator_test_handler_t** val, - struct _cef_translator_test_handler_t* val1, - struct _cef_translator_test_handler_t* val2) { + struct _cef_translator_test_ref_ptr_client_t** val, + struct _cef_translator_test_ref_ptr_client_t* val1, + struct _cef_translator_test_ref_ptr_client_t* val2) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -987,25 +995,25 @@ int CEF_CALLBACK translator_test_get_handler_list_by_ref( return 0; // Translate param: val; type: refptr_vec_diff_byref - std::vector > valList; + std::vector > valList; if (valCount && *valCount > 0 && val) { for (size_t i = 0; i < *valCount; ++i) { - valList.push_back(CefTranslatorTestHandlerCToCpp::Wrap(val[i])); + valList.push_back(CefTranslatorTestRefPtrClientCToCpp::Wrap(val[i])); } } // Execute - bool _retval = CefTranslatorTestCppToC::Get(self)->GetHandlerListByRef( + bool _retval = CefTranslatorTestCppToC::Get(self)->GetRefPtrClientListByRef( valList, - CefTranslatorTestHandlerCToCpp::Wrap(val1), - CefTranslatorTestHandlerCToCpp::Wrap(val2)); + CefTranslatorTestRefPtrClientCToCpp::Wrap(val1), + CefTranslatorTestRefPtrClientCToCpp::Wrap(val2)); // Restore param: val; type: refptr_vec_diff_byref if (valCount && val) { *valCount = std::min(valList.size(), *valCount); if (*valCount > 0) { for (size_t i = 0; i < *valCount; ++i) { - val[i] = CefTranslatorTestHandlerCToCpp::Unwrap(valList[i]); + val[i] = CefTranslatorTestRefPtrClientCToCpp::Unwrap(valList[i]); } } } @@ -1014,7 +1022,7 @@ int CEF_CALLBACK translator_test_get_handler_list_by_ref( return _retval; } -size_t CEF_CALLBACK translator_test_get_handler_list_size( +size_t CEF_CALLBACK translator_test_get_ref_ptr_client_list_size( struct _cef_translator_test_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1023,12 +1031,385 @@ size_t CEF_CALLBACK translator_test_get_handler_list_size( return 0; // Execute - size_t _retval = CefTranslatorTestCppToC::Get(self)->GetHandlerListSize(); + size_t _retval = CefTranslatorTestCppToC::Get(self)->GetRefPtrClientListSize( + ); // Return type: simple return _retval; } +struct _cef_translator_test_scoped_library_t* CEF_CALLBACK translator_test_get_own_ptr_library( + struct _cef_translator_test_t* self, int val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefOwnPtr _retval = + CefTranslatorTestCppToC::Get(self)->GetOwnPtrLibrary( + val); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCppToC::WrapOwn(OWN_PASS(_retval)); +} + +int CEF_CALLBACK translator_test_set_own_ptr_library( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: ownptr_same + DCHECK(val); + if (!val) + return 0; + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetOwnPtrLibrary( + CefTranslatorTestScopedLibraryCppToC::UnwrapOwn(val)); + + // Return type: simple + return _retval; +} + +struct _cef_translator_test_scoped_library_t* CEF_CALLBACK translator_test_set_own_ptr_library_and_return( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: val; type: ownptr_same + DCHECK(val); + if (!val) + return NULL; + + // Execute + CefOwnPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetOwnPtrLibraryAndReturn( + CefTranslatorTestScopedLibraryCppToC::UnwrapOwn(val)); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCppToC::WrapOwn(OWN_PASS(_retval)); +} + +int CEF_CALLBACK translator_test_set_child_own_ptr_library( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: ownptr_same + DCHECK(val); + if (!val) + return 0; + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetChildOwnPtrLibrary( + CefTranslatorTestScopedLibraryChildCppToC::UnwrapOwn(val)); + + // Return type: simple + return _retval; +} + +struct _cef_translator_test_scoped_library_t* CEF_CALLBACK translator_test_set_child_own_ptr_library_and_return_parent( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: val; type: ownptr_same + DCHECK(val); + if (!val) + return NULL; + + // Execute + CefOwnPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetChildOwnPtrLibraryAndReturnParent( + CefTranslatorTestScopedLibraryChildCppToC::UnwrapOwn(val)); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCppToC::WrapOwn(OWN_PASS(_retval)); +} + +int CEF_CALLBACK translator_test_set_own_ptr_client( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: ownptr_diff + DCHECK(val); + if (!val) + return 0; + + // Translate param: val; type: ownptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientCToCpp::Wrap(val)); + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetOwnPtrClient( + OWN_PASS(valPtr)); + + // Return type: simple + return _retval; +} + +struct _cef_translator_test_scoped_client_t* CEF_CALLBACK translator_test_set_own_ptr_client_and_return( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: val; type: ownptr_diff + DCHECK(val); + if (!val) + return NULL; + + // Translate param: val; type: ownptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientCToCpp::Wrap(val)); + + // Execute + CefOwnPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetOwnPtrClientAndReturn( + OWN_PASS(valPtr)); + + // Return type: ownptr_diff + return CefTranslatorTestScopedClientCToCpp::UnwrapOwn(OWN_PASS(_retval)); +} + +int CEF_CALLBACK translator_test_set_child_own_ptr_client( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: ownptr_diff + DCHECK(val); + if (!val) + return 0; + + // Translate param: val; type: ownptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientChildCToCpp::Wrap(val)); + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetChildOwnPtrClient( + OWN_PASS(valPtr)); + + // Return type: simple + return _retval; +} + +struct _cef_translator_test_scoped_client_t* CEF_CALLBACK translator_test_set_child_own_ptr_client_and_return_parent( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: val; type: ownptr_diff + DCHECK(val); + if (!val) + return NULL; + + // Translate param: val; type: ownptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientChildCToCpp::Wrap(val)); + + // Execute + CefOwnPtr _retval = + CefTranslatorTestCppToC::Get(self)->SetChildOwnPtrClientAndReturnParent( + OWN_PASS(valPtr)); + + // Return type: ownptr_diff + return CefTranslatorTestScopedClientCToCpp::UnwrapOwn(OWN_PASS(_retval)); +} + +int CEF_CALLBACK translator_test_set_raw_ptr_library( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: rawptr_same + DCHECK(val); + if (!val) + return 0; + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetRawPtrLibrary( + CefTranslatorTestScopedLibraryCppToC::UnwrapRaw(val)); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK translator_test_set_child_raw_ptr_library( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: rawptr_same + DCHECK(val); + if (!val) + return 0; + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetChildRawPtrLibrary( + CefTranslatorTestScopedLibraryChildCppToC::UnwrapRaw(val)); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK translator_test_set_raw_ptr_library_list( + struct _cef_translator_test_t* self, size_t valCount, + struct _cef_translator_test_scoped_library_t* const* val, int val1, + int val2) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: rawptr_vec_same_byref_const + DCHECK(valCount == 0 || val); + if (valCount > 0 && !val) + return 0; + + // Translate param: val; type: rawptr_vec_same_byref_const + std::vector > valList; + if (valCount > 0) { + for (size_t i = 0; i < valCount; ++i) { + CefRawPtr valVal = + CefTranslatorTestScopedLibraryCppToC::UnwrapRaw(val[i]); + valList.push_back(valVal); + } + } + + // Execute + bool _retval = CefTranslatorTestCppToC::Get(self)->SetRawPtrLibraryList( + valList, + val1, + val2); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK translator_test_set_raw_ptr_client( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: rawptr_diff + DCHECK(val); + if (!val) + return 0; + + // Translate param: val; type: rawptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientCToCpp::Wrap(val)); + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetRawPtrClient( + valPtr.get()); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK translator_test_set_child_raw_ptr_client( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: rawptr_diff + DCHECK(val); + if (!val) + return 0; + + // Translate param: val; type: rawptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientChildCToCpp::Wrap(val)); + + // Execute + int _retval = CefTranslatorTestCppToC::Get(self)->SetChildRawPtrClient( + valPtr.get()); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK translator_test_set_raw_ptr_client_list( + struct _cef_translator_test_t* self, size_t valCount, + struct _cef_translator_test_scoped_client_t* const* val, int val1, + int val2) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: val; type: rawptr_vec_diff_byref_const + DCHECK(valCount == 0 || val); + if (valCount > 0 && !val) + return 0; + + // Translate param: val; type: rawptr_vec_diff_byref_const + std::vector > valList; + if (valCount > 0) { + for (size_t i = 0; i < valCount; ++i) { + CefRawPtr valVal = + CefTranslatorTestScopedClientCToCpp::Wrap(val[i]).release(); + valList.push_back(valVal); + } + } + + // Execute + bool _retval = CefTranslatorTestCppToC::Get(self)->SetRawPtrClientList( + valList, + val1, + val2); + + // Restore param: val; type: rawptr_vec_diff_byref_const + if (valCount > 0) { + for (size_t i = 0; i < valCount; ++i) { + delete valList[i]; + } + } + + // Return type: bool + return _retval; +} + } // namespace @@ -1066,24 +1447,58 @@ CefTranslatorTestCppToC::CefTranslatorTestCppToC() { GetStruct()->set_point_list = translator_test_set_point_list; GetStruct()->get_point_list_by_ref = translator_test_get_point_list_by_ref; GetStruct()->get_point_list_size = translator_test_get_point_list_size; - GetStruct()->get_object = translator_test_get_object; - GetStruct()->set_object = translator_test_set_object; - GetStruct()->set_object_and_return = translator_test_set_object_and_return; - GetStruct()->set_child_object = translator_test_set_child_object; - GetStruct()->set_child_object_and_return_parent = - translator_test_set_child_object_and_return_parent; - GetStruct()->set_object_list = translator_test_set_object_list; - GetStruct()->get_object_list_by_ref = translator_test_get_object_list_by_ref; - GetStruct()->get_object_list_size = translator_test_get_object_list_size; - GetStruct()->set_handler = translator_test_set_handler; - GetStruct()->set_handler_and_return = translator_test_set_handler_and_return; - GetStruct()->set_child_handler = translator_test_set_child_handler; - GetStruct()->set_child_handler_and_return_parent = - translator_test_set_child_handler_and_return_parent; - GetStruct()->set_handler_list = translator_test_set_handler_list; - GetStruct()->get_handler_list_by_ref = - translator_test_get_handler_list_by_ref; - GetStruct()->get_handler_list_size = translator_test_get_handler_list_size; + GetStruct()->get_ref_ptr_library = translator_test_get_ref_ptr_library; + GetStruct()->set_ref_ptr_library = translator_test_set_ref_ptr_library; + GetStruct()->set_ref_ptr_library_and_return = + translator_test_set_ref_ptr_library_and_return; + GetStruct()->set_child_ref_ptr_library = + translator_test_set_child_ref_ptr_library; + GetStruct()->set_child_ref_ptr_library_and_return_parent = + translator_test_set_child_ref_ptr_library_and_return_parent; + GetStruct()->set_ref_ptr_library_list = + translator_test_set_ref_ptr_library_list; + GetStruct()->get_ref_ptr_library_list_by_ref = + translator_test_get_ref_ptr_library_list_by_ref; + GetStruct()->get_ref_ptr_library_list_size = + translator_test_get_ref_ptr_library_list_size; + GetStruct()->set_ref_ptr_client = translator_test_set_ref_ptr_client; + GetStruct()->set_ref_ptr_client_and_return = + translator_test_set_ref_ptr_client_and_return; + GetStruct()->set_child_ref_ptr_client = + translator_test_set_child_ref_ptr_client; + GetStruct()->set_child_ref_ptr_client_and_return_parent = + translator_test_set_child_ref_ptr_client_and_return_parent; + GetStruct()->set_ref_ptr_client_list = + translator_test_set_ref_ptr_client_list; + GetStruct()->get_ref_ptr_client_list_by_ref = + translator_test_get_ref_ptr_client_list_by_ref; + GetStruct()->get_ref_ptr_client_list_size = + translator_test_get_ref_ptr_client_list_size; + GetStruct()->get_own_ptr_library = translator_test_get_own_ptr_library; + GetStruct()->set_own_ptr_library = translator_test_set_own_ptr_library; + GetStruct()->set_own_ptr_library_and_return = + translator_test_set_own_ptr_library_and_return; + GetStruct()->set_child_own_ptr_library = + translator_test_set_child_own_ptr_library; + GetStruct()->set_child_own_ptr_library_and_return_parent = + translator_test_set_child_own_ptr_library_and_return_parent; + GetStruct()->set_own_ptr_client = translator_test_set_own_ptr_client; + GetStruct()->set_own_ptr_client_and_return = + translator_test_set_own_ptr_client_and_return; + GetStruct()->set_child_own_ptr_client = + translator_test_set_child_own_ptr_client; + GetStruct()->set_child_own_ptr_client_and_return_parent = + translator_test_set_child_own_ptr_client_and_return_parent; + GetStruct()->set_raw_ptr_library = translator_test_set_raw_ptr_library; + GetStruct()->set_child_raw_ptr_library = + translator_test_set_child_raw_ptr_library; + GetStruct()->set_raw_ptr_library_list = + translator_test_set_raw_ptr_library_list; + GetStruct()->set_raw_ptr_client = translator_test_set_raw_ptr_client; + GetStruct()->set_child_raw_ptr_client = + translator_test_set_child_raw_ptr_client; + GetStruct()->set_raw_ptr_client_list = + translator_test_set_raw_ptr_client_list; } template<> CefRefPtr CefCppToCGetOtherValue(); - - // Return type: simple - return _retval; -} - -int CEF_CALLBACK translator_test_handler_child_get_value( - struct _cef_translator_test_handler_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestHandlerChildCppToC::Get( - reinterpret_cast(self))->GetValue( - ); - - // Return type: simple - return _retval; -} - -} // namespace - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestHandlerChildCppToC::CefTranslatorTestHandlerChildCppToC() { - GetStruct()->get_other_value = translator_test_handler_child_get_other_value; - GetStruct()->base.get_value = translator_test_handler_child_get_value; -} - -template<> CefRefPtr CefCppToC::UnwrapDerived(CefWrapperType type, - cef_translator_test_handler_child_t* s) { - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCppToC::kWrapperType = - WT_TRANSLATOR_TEST_HANDLER_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_handler_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_handler_cpptoc.cc deleted file mode 100644 index 01a6caeaa..000000000 --- a/libcef_dll/cpptoc/test/translator_test_handler_cpptoc.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h" - - -namespace { - -// MEMBER FUNCTIONS - Body may be edited by hand. - -int CEF_CALLBACK translator_test_handler_get_value( - struct _cef_translator_test_handler_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestHandlerCppToC::Get(self)->GetValue(); - - // Return type: simple - return _retval; -} - -} // namespace - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestHandlerCppToC::CefTranslatorTestHandlerCppToC() { - GetStruct()->get_value = translator_test_handler_get_value; -} - -template<> CefRefPtr CefCppToC::UnwrapDerived( - CefWrapperType type, cef_translator_test_handler_t* s) { - if (type == WT_TRANSLATOR_TEST_HANDLER_CHILD) { - return CefTranslatorTestHandlerChildCppToC::Unwrap( - reinterpret_cast(s)); - } - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCppToC::kWrapperType = - WT_TRANSLATOR_TEST_HANDLER; diff --git a/libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.cc deleted file mode 100644 index 0faac2599..000000000 --- a/libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.cc +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h" - - -// GLOBAL FUNCTIONS - Body may be edited by hand. - -CEF_EXPORT cef_translator_test_object_child_child_t* cef_translator_test_object_child_child_create( - int value, int other_value, int other_other_value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - CefRefPtr _retval = - CefTranslatorTestObjectChildChild::Create( - value, - other_value, - other_other_value); - - // Return type: refptr_same - return CefTranslatorTestObjectChildChildCppToC::Wrap(_retval); -} - - -namespace { - -// MEMBER FUNCTIONS - Body may be edited by hand. - -int CEF_CALLBACK translator_test_object_child_child_get_other_other_value( - struct _cef_translator_test_object_child_child_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestObjectChildChildCppToC::Get( - self)->GetOtherOtherValue(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK translator_test_object_child_child_set_other_other_value( - struct _cef_translator_test_object_child_child_t* self, int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefTranslatorTestObjectChildChildCppToC::Get(self)->SetOtherOtherValue( - value); -} - -int CEF_CALLBACK translator_test_object_child_child_get_other_value( - struct _cef_translator_test_object_child_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestObjectChildChildCppToC::Get( - reinterpret_cast( - self))->GetOtherValue(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK translator_test_object_child_child_set_other_value( - struct _cef_translator_test_object_child_t* self, int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefTranslatorTestObjectChildChildCppToC::Get( - reinterpret_cast( - self))->SetOtherValue( - value); -} - -int CEF_CALLBACK translator_test_object_child_child_get_value( - struct _cef_translator_test_object_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestObjectChildChildCppToC::Get( - reinterpret_cast( - self))->GetValue(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK translator_test_object_child_child_set_value( - struct _cef_translator_test_object_t* self, int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefTranslatorTestObjectChildChildCppToC::Get( - reinterpret_cast( - self))->SetValue( - value); -} - -} // namespace - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestObjectChildChildCppToC::CefTranslatorTestObjectChildChildCppToC( - ) { - GetStruct()->get_other_other_value = - translator_test_object_child_child_get_other_other_value; - GetStruct()->set_other_other_value = - translator_test_object_child_child_set_other_other_value; - GetStruct()->base.get_other_value = - translator_test_object_child_child_get_other_value; - GetStruct()->base.set_other_value = - translator_test_object_child_child_set_other_value; - GetStruct()->base.base.get_value = - translator_test_object_child_child_get_value; - GetStruct()->base.base.set_value = - translator_test_object_child_child_set_value; -} - -template<> CefRefPtr CefCppToC::UnwrapDerived( - CefWrapperType type, cef_translator_test_object_child_child_t* s) { - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCppToC::kWrapperType = - WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.cc deleted file mode 100644 index 7bd036dcd..000000000 --- a/libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.cc +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h" - - -// GLOBAL FUNCTIONS - Body may be edited by hand. - -CEF_EXPORT cef_translator_test_object_child_t* cef_translator_test_object_child_create( - int value, int other_value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - CefRefPtr _retval = - CefTranslatorTestObjectChild::Create( - value, - other_value); - - // Return type: refptr_same - return CefTranslatorTestObjectChildCppToC::Wrap(_retval); -} - - -namespace { - -// MEMBER FUNCTIONS - Body may be edited by hand. - -int CEF_CALLBACK translator_test_object_child_get_other_value( - struct _cef_translator_test_object_child_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestObjectChildCppToC::Get(self)->GetOtherValue(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK translator_test_object_child_set_other_value( - struct _cef_translator_test_object_child_t* self, int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefTranslatorTestObjectChildCppToC::Get(self)->SetOtherValue( - value); -} - -int CEF_CALLBACK translator_test_object_child_get_value( - struct _cef_translator_test_object_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestObjectChildCppToC::Get( - reinterpret_cast(self))->GetValue(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK translator_test_object_child_set_value( - struct _cef_translator_test_object_t* self, int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefTranslatorTestObjectChildCppToC::Get( - reinterpret_cast(self))->SetValue( - value); -} - -} // namespace - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestObjectChildCppToC::CefTranslatorTestObjectChildCppToC() { - GetStruct()->get_other_value = translator_test_object_child_get_other_value; - GetStruct()->set_other_value = translator_test_object_child_set_other_value; - GetStruct()->base.get_value = translator_test_object_child_get_value; - GetStruct()->base.set_value = translator_test_object_child_set_value; -} - -template<> CefRefPtr CefCppToC::UnwrapDerived(CefWrapperType type, - cef_translator_test_object_child_t* s) { - if (type == WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD) { - return CefTranslatorTestObjectChildChildCppToC::Unwrap( - reinterpret_cast(s)); - } - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCppToC::kWrapperType = - WT_TRANSLATOR_TEST_OBJECT_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_object_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_object_cpptoc.cc deleted file mode 100644 index cb49308d6..000000000 --- a/libcef_dll/cpptoc/test/translator_test_object_cpptoc.cc +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/test/translator_test_object_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h" - - -// GLOBAL FUNCTIONS - Body may be edited by hand. - -CEF_EXPORT cef_translator_test_object_t* cef_translator_test_object_create( - int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - CefRefPtr _retval = CefTranslatorTestObject::Create( - value); - - // Return type: refptr_same - return CefTranslatorTestObjectCppToC::Wrap(_retval); -} - - -namespace { - -// MEMBER FUNCTIONS - Body may be edited by hand. - -int CEF_CALLBACK translator_test_object_get_value( - struct _cef_translator_test_object_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - int _retval = CefTranslatorTestObjectCppToC::Get(self)->GetValue(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK translator_test_object_set_value( - struct _cef_translator_test_object_t* self, int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefTranslatorTestObjectCppToC::Get(self)->SetValue( - value); -} - -} // namespace - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestObjectCppToC::CefTranslatorTestObjectCppToC() { - GetStruct()->get_value = translator_test_object_get_value; - GetStruct()->set_value = translator_test_object_set_value; -} - -template<> CefRefPtr CefCppToC::UnwrapDerived( - CefWrapperType type, cef_translator_test_object_t* s) { - if (type == WT_TRANSLATOR_TEST_OBJECT_CHILD) { - return CefTranslatorTestObjectChildCppToC::Unwrap( - reinterpret_cast(s)); - } - if (type == WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD) { - return CefTranslatorTestObjectChildChildCppToC::Unwrap( - reinterpret_cast(s)); - } - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCppToC::kWrapperType = - WT_TRANSLATOR_TEST_OBJECT; diff --git a/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.cc new file mode 100644 index 000000000..2698bcf1e --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.cc @@ -0,0 +1,82 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h" + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_ref_ptr_client_child_get_other_value( + struct _cef_translator_test_ref_ptr_client_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrClientChildCppToC::Get( + self)->GetOtherValue(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK translator_test_ref_ptr_client_child_get_value( + struct _cef_translator_test_ref_ptr_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrClientChildCppToC::Get( + reinterpret_cast( + self))->GetValue(); + + // Return type: simple + return _retval; +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrClientChildCppToC::CefTranslatorTestRefPtrClientChildCppToC( + ) { + GetStruct()->get_other_value = + translator_test_ref_ptr_client_child_get_other_value; + GetStruct()->base.get_value = translator_test_ref_ptr_client_child_get_value; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived( + CefWrapperType type, cef_translator_test_ref_ptr_client_child_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h similarity index 63% rename from libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h rename to libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h index a030eec8b..9c36a40b1 100644 --- a/libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_HANDLER_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_HANDLER_CPPTOC_H_ +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD_CPPTOC_H_ #pragma once #if !defined(WRAPPING_CEF_SHARED) @@ -24,11 +24,12 @@ // Wrap a C++ class with a C structure. // This class may be instantiated and accessed wrapper-side only. -class CefTranslatorTestHandlerCppToC - : public CefCppToC { +class CefTranslatorTestRefPtrClientChildCppToC + : public CefCppToC { public: - CefTranslatorTestHandlerCppToC(); + CefTranslatorTestRefPtrClientChildCppToC(); }; -#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_HANDLER_CPPTOC_H_ +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.cc new file mode 100644 index 000000000..96d6a39fd --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h" + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_ref_ptr_client_get_value( + struct _cef_translator_test_ref_ptr_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrClientCppToC::Get(self)->GetValue(); + + // Return type: simple + return _retval; +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrClientCppToC::CefTranslatorTestRefPtrClientCppToC() { + GetStruct()->get_value = translator_test_ref_ptr_client_get_value; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived(CefWrapperType type, + cef_translator_test_ref_ptr_client_t* s) { + if (type == WT_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD) { + return CefTranslatorTestRefPtrClientChildCppToC::Unwrap( + reinterpret_cast(s)); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_CLIENT; diff --git a/libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h similarity index 66% rename from libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h rename to libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h index 1fc18e453..c8c14aeb8 100644 --- a/libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_HANDLER_CHILD_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_HANDLER_CHILD_CPPTOC_H_ +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CPPTOC_H_ #pragma once #if !defined(WRAPPING_CEF_SHARED) @@ -24,11 +24,11 @@ // Wrap a C++ class with a C structure. // This class may be instantiated and accessed wrapper-side only. -class CefTranslatorTestHandlerChildCppToC - : public CefCppToC { +class CefTranslatorTestRefPtrClientCppToC + : public CefCppToC { public: - CefTranslatorTestHandlerChildCppToC(); + CefTranslatorTestRefPtrClientCppToC(); }; -#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_HANDLER_CHILD_CPPTOC_H_ +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.cc new file mode 100644 index 000000000..548d45fe5 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.cc @@ -0,0 +1,171 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_translator_test_ref_ptr_library_child_child_t* cef_translator_test_ref_ptr_library_child_child_create( + int value, int other_value, int other_other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = + CefTranslatorTestRefPtrLibraryChildChild::Create( + value, + other_value, + other_other_value); + + // Return type: refptr_same + return CefTranslatorTestRefPtrLibraryChildChildCppToC::Wrap(_retval); +} + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_ref_ptr_library_child_child_get_other_other_value( + struct _cef_translator_test_ref_ptr_library_child_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrLibraryChildChildCppToC::Get( + self)->GetOtherOtherValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_ref_ptr_library_child_child_set_other_other_value( + struct _cef_translator_test_ref_ptr_library_child_child_t* self, + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestRefPtrLibraryChildChildCppToC::Get(self)->SetOtherOtherValue( + value); +} + +int CEF_CALLBACK translator_test_ref_ptr_library_child_child_get_other_value( + struct _cef_translator_test_ref_ptr_library_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->GetOtherValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_ref_ptr_library_child_child_set_other_value( + struct _cef_translator_test_ref_ptr_library_child_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestRefPtrLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->SetOtherValue( + value); +} + +int CEF_CALLBACK translator_test_ref_ptr_library_child_child_get_value( + struct _cef_translator_test_ref_ptr_library_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->GetValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_ref_ptr_library_child_child_set_value( + struct _cef_translator_test_ref_ptr_library_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestRefPtrLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->SetValue( + value); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrLibraryChildChildCppToC::CefTranslatorTestRefPtrLibraryChildChildCppToC( + ) { + GetStruct()->get_other_other_value = + translator_test_ref_ptr_library_child_child_get_other_other_value; + GetStruct()->set_other_other_value = + translator_test_ref_ptr_library_child_child_set_other_other_value; + GetStruct()->base.get_other_value = + translator_test_ref_ptr_library_child_child_get_other_value; + GetStruct()->base.set_other_value = + translator_test_ref_ptr_library_child_child_set_other_value; + GetStruct()->base.base.get_value = + translator_test_ref_ptr_library_child_child_get_value; + GetStruct()->base.base.set_value = + translator_test_ref_ptr_library_child_child_set_value; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived( + CefWrapperType type, + cef_translator_test_ref_ptr_library_child_child_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h new file mode 100644 index 000000000..ebddb29db --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h @@ -0,0 +1,35 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD_CPPTOC_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefTranslatorTestRefPtrLibraryChildChildCppToC + : public CefCppToC { + public: + CefTranslatorTestRefPtrLibraryChildChildCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.cc new file mode 100644 index 000000000..4aff1f509 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.cc @@ -0,0 +1,136 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_translator_test_ref_ptr_library_child_t* cef_translator_test_ref_ptr_library_child_create( + int value, int other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = + CefTranslatorTestRefPtrLibraryChild::Create( + value, + other_value); + + // Return type: refptr_same + return CefTranslatorTestRefPtrLibraryChildCppToC::Wrap(_retval); +} + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_ref_ptr_library_child_get_other_value( + struct _cef_translator_test_ref_ptr_library_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrLibraryChildCppToC::Get( + self)->GetOtherValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_ref_ptr_library_child_set_other_value( + struct _cef_translator_test_ref_ptr_library_child_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestRefPtrLibraryChildCppToC::Get(self)->SetOtherValue( + value); +} + +int CEF_CALLBACK translator_test_ref_ptr_library_child_get_value( + struct _cef_translator_test_ref_ptr_library_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrLibraryChildCppToC::Get( + reinterpret_cast( + self))->GetValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_ref_ptr_library_child_set_value( + struct _cef_translator_test_ref_ptr_library_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestRefPtrLibraryChildCppToC::Get( + reinterpret_cast( + self))->SetValue( + value); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrLibraryChildCppToC::CefTranslatorTestRefPtrLibraryChildCppToC( + ) { + GetStruct()->get_other_value = + translator_test_ref_ptr_library_child_get_other_value; + GetStruct()->set_other_value = + translator_test_ref_ptr_library_child_set_other_value; + GetStruct()->base.get_value = translator_test_ref_ptr_library_child_get_value; + GetStruct()->base.set_value = translator_test_ref_ptr_library_child_set_value; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived( + CefWrapperType type, cef_translator_test_ref_ptr_library_child_t* s) { + if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD) { + return CefTranslatorTestRefPtrLibraryChildChildCppToC::Unwrap( + reinterpret_cast( + s)); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h similarity index 63% rename from libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h rename to libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h index 0faa07430..688ae461e 100644 --- a/libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CHILD_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CHILD_CPPTOC_H_ +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CPPTOC_H_ #pragma once #if !defined(BUILDING_CEF_SHARED) @@ -24,12 +24,12 @@ // Wrap a C++ class with a C structure. // This class may be instantiated and accessed DLL-side only. -class CefTranslatorTestObjectChildChildCppToC - : public CefCppToC { +class CefTranslatorTestRefPtrLibraryChildCppToC + : public CefCppToC { public: - CefTranslatorTestObjectChildChildCppToC(); + CefTranslatorTestRefPtrLibraryChildCppToC(); }; -#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CHILD_CPPTOC_H_ +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.cc new file mode 100644 index 000000000..893e34064 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.cc @@ -0,0 +1,102 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_translator_test_ref_ptr_library_t* cef_translator_test_ref_ptr_library_create( + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = + CefTranslatorTestRefPtrLibrary::Create( + value); + + // Return type: refptr_same + return CefTranslatorTestRefPtrLibraryCppToC::Wrap(_retval); +} + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_ref_ptr_library_get_value( + struct _cef_translator_test_ref_ptr_library_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestRefPtrLibraryCppToC::Get(self)->GetValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_ref_ptr_library_set_value( + struct _cef_translator_test_ref_ptr_library_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestRefPtrLibraryCppToC::Get(self)->SetValue( + value); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrLibraryCppToC::CefTranslatorTestRefPtrLibraryCppToC() { + GetStruct()->get_value = translator_test_ref_ptr_library_get_value; + GetStruct()->set_value = translator_test_ref_ptr_library_set_value; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived(CefWrapperType type, + cef_translator_test_ref_ptr_library_t* s) { + if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD) { + return CefTranslatorTestRefPtrLibraryChildCppToC::Unwrap( + reinterpret_cast(s)); + } + if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD) { + return CefTranslatorTestRefPtrLibraryChildChildCppToC::Unwrap( + reinterpret_cast( + s)); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY; diff --git a/libcef_dll/cpptoc/test/translator_test_object_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h similarity index 65% rename from libcef_dll/cpptoc/test/translator_test_object_cpptoc.h rename to libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h index 795f314e2..c41d93357 100644 --- a/libcef_dll/cpptoc/test/translator_test_object_cpptoc.h +++ b/libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CPPTOC_H_ +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CPPTOC_H_ #pragma once #if !defined(BUILDING_CEF_SHARED) @@ -24,11 +24,12 @@ // Wrap a C++ class with a C structure. // This class may be instantiated and accessed DLL-side only. -class CefTranslatorTestObjectCppToC - : public CefCppToC { +class CefTranslatorTestRefPtrLibraryCppToC + : public CefCppToC { public: - CefTranslatorTestObjectCppToC(); + CefTranslatorTestRefPtrLibraryCppToC(); }; -#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CPPTOC_H_ +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.cc new file mode 100644 index 000000000..255a08b51 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.cc @@ -0,0 +1,90 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h" + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_scoped_client_child_get_other_value( + struct _cef_translator_test_scoped_client_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedClientChildCppToC::Get( + self)->GetOtherValue(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK translator_test_scoped_client_child_get_value( + struct _cef_translator_test_scoped_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedClientChildCppToC::Get( + reinterpret_cast( + self))->GetValue(); + + // Return type: simple + return _retval; +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedClientChildCppToC::CefTranslatorTestScopedClientChildCppToC( + ) { + GetStruct()->get_other_value = + translator_test_scoped_client_child_get_other_value; + GetStruct()->base.get_value = translator_test_scoped_client_child_get_value; +} + +template<> CefOwnPtr CefCppToCScoped::UnwrapDerivedOwn( + CefWrapperType type, cef_translator_test_scoped_client_child_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return CefOwnPtr(); +} + +template<> CefRawPtr CefCppToCScoped::UnwrapDerivedRaw( + CefWrapperType type, cef_translator_test_scoped_client_child_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToCScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h new file mode 100644 index 000000000..87a73ba79 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h @@ -0,0 +1,35 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD_CPPTOC_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefTranslatorTestScopedClientChildCppToC + : public CefCppToCScoped { + public: + CefTranslatorTestScopedClientChildCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.cc new file mode 100644 index 000000000..c34f9ff12 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h" + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_scoped_client_get_value( + struct _cef_translator_test_scoped_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedClientCppToC::Get(self)->GetValue(); + + // Return type: simple + return _retval; +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedClientCppToC::CefTranslatorTestScopedClientCppToC() { + GetStruct()->get_value = translator_test_scoped_client_get_value; +} + +template<> CefOwnPtr CefCppToCScoped::UnwrapDerivedOwn(CefWrapperType type, + cef_translator_test_scoped_client_t* s) { + if (type == WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD) { + return OWN_RETURN_AS(CefTranslatorTestScopedClientChildCppToC::UnwrapOwn( + reinterpret_cast(s)), + CefTranslatorTestScopedClient); + } + NOTREACHED() << "Unexpected class type: " << type; + return CefOwnPtr(); +} + +template<> CefRawPtr CefCppToCScoped::UnwrapDerivedRaw(CefWrapperType type, + cef_translator_test_scoped_client_t* s) { + if (type == WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD) { + return CefTranslatorTestScopedClientChildCppToC::UnwrapRaw( + reinterpret_cast(s)); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToCScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_CLIENT; diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h new file mode 100644 index 000000000..be91cd6eb --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h @@ -0,0 +1,34 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CPPTOC_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefTranslatorTestScopedClientCppToC + : public CefCppToCScoped { + public: + CefTranslatorTestScopedClientCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.cc new file mode 100644 index 000000000..5e9f7e1d2 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.cc @@ -0,0 +1,179 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_translator_test_scoped_library_child_child_t* cef_translator_test_scoped_library_child_child_create( + int value, int other_value, int other_other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefOwnPtr _retval = + CefTranslatorTestScopedLibraryChildChild::Create( + value, + other_value, + other_other_value); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryChildChildCppToC::WrapOwn(OWN_PASS( + _retval)); +} + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_scoped_library_child_child_get_other_other_value( + struct _cef_translator_test_scoped_library_child_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedLibraryChildChildCppToC::Get( + self)->GetOtherOtherValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_scoped_library_child_child_set_other_other_value( + struct _cef_translator_test_scoped_library_child_child_t* self, + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestScopedLibraryChildChildCppToC::Get(self)->SetOtherOtherValue( + value); +} + +int CEF_CALLBACK translator_test_scoped_library_child_child_get_other_value( + struct _cef_translator_test_scoped_library_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->GetOtherValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_scoped_library_child_child_set_other_value( + struct _cef_translator_test_scoped_library_child_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestScopedLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->SetOtherValue( + value); +} + +int CEF_CALLBACK translator_test_scoped_library_child_child_get_value( + struct _cef_translator_test_scoped_library_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->GetValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_scoped_library_child_child_set_value( + struct _cef_translator_test_scoped_library_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestScopedLibraryChildChildCppToC::Get( + reinterpret_cast( + self))->SetValue( + value); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedLibraryChildChildCppToC::CefTranslatorTestScopedLibraryChildChildCppToC( + ) { + GetStruct()->get_other_other_value = + translator_test_scoped_library_child_child_get_other_other_value; + GetStruct()->set_other_other_value = + translator_test_scoped_library_child_child_set_other_other_value; + GetStruct()->base.get_other_value = + translator_test_scoped_library_child_child_get_other_value; + GetStruct()->base.set_other_value = + translator_test_scoped_library_child_child_set_other_value; + GetStruct()->base.base.get_value = + translator_test_scoped_library_child_child_get_value; + GetStruct()->base.base.set_value = + translator_test_scoped_library_child_child_set_value; +} + +template<> CefOwnPtr CefCppToCScoped::UnwrapDerivedOwn( + CefWrapperType type, cef_translator_test_scoped_library_child_child_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return CefOwnPtr(); +} + +template<> CefRawPtr CefCppToCScoped::UnwrapDerivedRaw( + CefWrapperType type, cef_translator_test_scoped_library_child_child_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToCScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h new file mode 100644 index 000000000..d0d2ed71c --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h @@ -0,0 +1,35 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD_CPPTOC_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefTranslatorTestScopedLibraryChildChildCppToC + : public CefCppToCScoped { + public: + CefTranslatorTestScopedLibraryChildChildCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.cc new file mode 100644 index 000000000..13195b90c --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.cc @@ -0,0 +1,150 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_translator_test_scoped_library_child_t* cef_translator_test_scoped_library_child_create( + int value, int other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefOwnPtr _retval = + CefTranslatorTestScopedLibraryChild::Create( + value, + other_value); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryChildCppToC::WrapOwn(OWN_PASS(_retval)); +} + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_scoped_library_child_get_other_value( + struct _cef_translator_test_scoped_library_child_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedLibraryChildCppToC::Get( + self)->GetOtherValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_scoped_library_child_set_other_value( + struct _cef_translator_test_scoped_library_child_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestScopedLibraryChildCppToC::Get(self)->SetOtherValue( + value); +} + +int CEF_CALLBACK translator_test_scoped_library_child_get_value( + struct _cef_translator_test_scoped_library_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedLibraryChildCppToC::Get( + reinterpret_cast( + self))->GetValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_scoped_library_child_set_value( + struct _cef_translator_test_scoped_library_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestScopedLibraryChildCppToC::Get( + reinterpret_cast( + self))->SetValue( + value); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedLibraryChildCppToC::CefTranslatorTestScopedLibraryChildCppToC( + ) { + GetStruct()->get_other_value = + translator_test_scoped_library_child_get_other_value; + GetStruct()->set_other_value = + translator_test_scoped_library_child_set_other_value; + GetStruct()->base.get_value = translator_test_scoped_library_child_get_value; + GetStruct()->base.set_value = translator_test_scoped_library_child_set_value; +} + +template<> CefOwnPtr CefCppToCScoped::UnwrapDerivedOwn( + CefWrapperType type, cef_translator_test_scoped_library_child_t* s) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return OWN_RETURN_AS( + CefTranslatorTestScopedLibraryChildChildCppToC::UnwrapOwn( + reinterpret_cast(s)), + CefTranslatorTestScopedLibraryChild); + } + NOTREACHED() << "Unexpected class type: " << type; + return CefOwnPtr(); +} + +template<> CefRawPtr CefCppToCScoped::UnwrapDerivedRaw( + CefWrapperType type, cef_translator_test_scoped_library_child_t* s) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return CefTranslatorTestScopedLibraryChildChildCppToC::UnwrapRaw( + reinterpret_cast( + s)); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToCScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD; diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h new file mode 100644 index 000000000..63a83d881 --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h @@ -0,0 +1,35 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CPPTOC_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefTranslatorTestScopedLibraryChildCppToC + : public CefCppToCScoped { + public: + CefTranslatorTestScopedLibraryChildCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.cc b/libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.cc new file mode 100644 index 000000000..6864677af --- /dev/null +++ b/libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.cc @@ -0,0 +1,121 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_translator_test_scoped_library_t* cef_translator_test_scoped_library_create( + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefOwnPtr _retval = + CefTranslatorTestScopedLibrary::Create( + value); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCppToC::WrapOwn(OWN_PASS(_retval)); +} + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK translator_test_scoped_library_get_value( + struct _cef_translator_test_scoped_library_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTranslatorTestScopedLibraryCppToC::Get(self)->GetValue(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK translator_test_scoped_library_set_value( + struct _cef_translator_test_scoped_library_t* self, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTranslatorTestScopedLibraryCppToC::Get(self)->SetValue( + value); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedLibraryCppToC::CefTranslatorTestScopedLibraryCppToC() { + GetStruct()->get_value = translator_test_scoped_library_get_value; + GetStruct()->set_value = translator_test_scoped_library_set_value; +} + +template<> CefOwnPtr CefCppToCScoped::UnwrapDerivedOwn( + CefWrapperType type, cef_translator_test_scoped_library_t* s) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD) { + return OWN_RETURN_AS(CefTranslatorTestScopedLibraryChildCppToC::UnwrapOwn( + reinterpret_cast(s)), + CefTranslatorTestScopedLibrary); + } + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return OWN_RETURN_AS( + CefTranslatorTestScopedLibraryChildChildCppToC::UnwrapOwn( + reinterpret_cast(s)), + CefTranslatorTestScopedLibrary); + } + NOTREACHED() << "Unexpected class type: " << type; + return CefOwnPtr(); +} + +template<> CefRawPtr CefCppToCScoped::UnwrapDerivedRaw( + CefWrapperType type, cef_translator_test_scoped_library_t* s) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD) { + return CefTranslatorTestScopedLibraryChildCppToC::UnwrapRaw( + reinterpret_cast(s)); + } + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return CefTranslatorTestScopedLibraryChildChildCppToC::UnwrapRaw( + reinterpret_cast( + s)); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToCScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToCScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_LIBRARY; diff --git a/libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h b/libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h similarity index 62% rename from libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h rename to libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h index c84bcf203..4b023f7fe 100644 --- a/libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h +++ b/libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CPPTOC_H_ +#ifndef CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CPPTOC_H_ #pragma once #if !defined(BUILDING_CEF_SHARED) @@ -20,15 +20,16 @@ #include "include/test/cef_translator_test.h" #include "include/capi/test/cef_translator_test_capi.h" -#include "libcef_dll/cpptoc/cpptoc.h" +#include "libcef_dll/cpptoc/cpptoc_scoped.h" // Wrap a C++ class with a C structure. // This class may be instantiated and accessed DLL-side only. -class CefTranslatorTestObjectChildCppToC - : public CefCppToC { +class CefTranslatorTestScopedLibraryCppToC + : public CefCppToCScoped { public: - CefTranslatorTestObjectChildCppToC(); + CefTranslatorTestScopedLibraryCppToC(); }; -#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CPPTOC_H_ +#endif // CEF_LIBCEF_DLL_CPPTOC_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CPPTOC_H_ diff --git a/libcef_dll/ctocpp/app_ctocpp.cc b/libcef_dll/ctocpp/app_ctocpp.cc index 458ea1c51..43c4e2e5a 100644 --- a/libcef_dll/ctocpp/app_ctocpp.cc +++ b/libcef_dll/ctocpp/app_ctocpp.cc @@ -41,21 +41,25 @@ void CefAppCToCpp::OnBeforeCommandLineProcessing(const CefString& process_type, } void CefAppCToCpp::OnRegisterCustomSchemes( - CefRefPtr registrar) { + CefRawPtr registrar) { cef_app_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, on_register_custom_schemes)) return; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: registrar; type: refptr_diff - DCHECK(registrar.get()); - if (!registrar.get()) + // Verify param: registrar; type: rawptr_diff + DCHECK(registrar); + if (!registrar) return; + // Translate param: registrar; type: rawptr_diff + CefOwnPtr registrarPtr( + CefSchemeRegistrarCppToC::WrapRaw(registrar)); + // Execute _struct->on_register_custom_schemes(_struct, - CefSchemeRegistrarCppToC::Wrap(registrar)); + registrarPtr->GetStruct()); } CefRefPtr CefAppCToCpp::GetResourceBundleHandler() { diff --git a/libcef_dll/ctocpp/app_ctocpp.h b/libcef_dll/ctocpp/app_ctocpp.h index 3d0538643..2f6975e56 100644 --- a/libcef_dll/ctocpp/app_ctocpp.h +++ b/libcef_dll/ctocpp/app_ctocpp.h @@ -33,7 +33,7 @@ class CefAppCToCpp void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr command_line) override; void OnRegisterCustomSchemes( - CefRefPtr registrar) override; + CefRawPtr registrar) override; CefRefPtr GetResourceBundleHandler() override; CefRefPtr GetBrowserProcessHandler() override; CefRefPtr GetRenderProcessHandler() override; diff --git a/libcef_dll/ctocpp/base_scoped_ctocpp.cc b/libcef_dll/ctocpp/base_scoped_ctocpp.cc new file mode 100644 index 000000000..2ee3a70c8 --- /dev/null +++ b/libcef_dll/ctocpp/base_scoped_ctocpp.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2017 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 "libcef_dll/ctocpp/base_scoped_ctocpp.h" + +CefBaseScopedCToCpp::CefBaseScopedCToCpp() { +} + +template<> cef_base_scoped_t* +CefCToCppScoped:: + UnwrapDerivedOwn(CefWrapperType type, CefOwnPtr c) { + NOTREACHED(); + return NULL; +} + +template<> cef_base_scoped_t* +CefCToCppScoped:: + UnwrapDerivedRaw(CefWrapperType type, CefRawPtr c) { + NOTREACHED(); + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCppScoped::kWrapperType = WT_BASE; diff --git a/libcef_dll/ctocpp/base_scoped_ctocpp.h b/libcef_dll/ctocpp/base_scoped_ctocpp.h new file mode 100644 index 000000000..0924c1df5 --- /dev/null +++ b/libcef_dll/ctocpp/base_scoped_ctocpp.h @@ -0,0 +1,25 @@ +// Copyright (c) 2017 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 CEF_LIBCEF_DLL_CTOCPP_BASE_SCOPED_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BASE_SCOPED_CTOCPP_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +// Wrap a C structure with a C++ class. +class CefBaseScopedCToCpp + : public CefCToCppScoped { + public: + CefBaseScopedCToCpp(); +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_BASE_SCOPED_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/ctocpp.h b/libcef_dll/ctocpp/ctocpp.h index 83ee30822..85ca5fc6d 100644 --- a/libcef_dll/ctocpp/ctocpp.h +++ b/libcef_dll/ctocpp/ctocpp.h @@ -26,16 +26,6 @@ class CefCToCpp : public BaseName { // return back to the other side. static StructName* Unwrap(CefRefPtr c); - // 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() const { - WrapperStruct* wrapperStruct = GetWrapperStruct(this); - // Verify that the wrapper offset was calculated correctly. - DCHECK_EQ(kWrapperType, wrapperStruct->type_); - return wrapperStruct->struct_; - } - // CefBase methods increment/decrement reference counts on both this object // and the underlying wrapped structure. void AddRef() const { @@ -63,6 +53,14 @@ class CefCToCpp : public BaseName { #endif } + // If returning the structure across the DLL boundary use Unwrap() instead. + StructName* GetStruct() const { + WrapperStruct* wrapperStruct = GetWrapperStruct(this); + // Verify that the wrapper offset was calculated correctly. + DCHECK_EQ(kWrapperType, wrapperStruct->type_); + return wrapperStruct->struct_; + } + private: // Used to associate this wrapper object and the structure reference received // from the other side. diff --git a/libcef_dll/ctocpp/ctocpp_scoped.h b/libcef_dll/ctocpp/ctocpp_scoped.h new file mode 100644 index 000000000..8b32de704 --- /dev/null +++ b/libcef_dll/ctocpp/ctocpp_scoped.h @@ -0,0 +1,211 @@ +// Copyright (c) 2017 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 CEF_LIBCEF_DLL_CTOCPP_CTOCPP_SCOPED_H_ +#define CEF_LIBCEF_DLL_CTOCPP_CTOCPP_SCOPED_H_ +#pragma once + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/ptr_util.h" +#include "libcef_dll/wrapper_types.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 CefCToCppScoped : public BaseName { + public: + // Create a new wrapper instance for a structure reference received from the + // other side. The caller owns the CToCpp wrapper instance but not necessarily + // the underling object on the CppToC side (depends if s->del is non-NULL). + // The returned wrapper object can be used as either a scoped argument or to + // pass ownership. For example: + // + // void my_method(my_type1_t* struct1, my_type2_t* struct2) { + // // Passes ownership to MyMethod1(). + // MyMethod1(MyType1CToCpp::Wrap(struct1)); + // + // // Passes reference to MyMethod2(). + // CefOwnPtr obj2 = MyType2CToCpp::Wrap(struct2); + // MyMethod2(obj2.get()); + // // |obj2| is deleted when my_method() goes out of scope. + // } + // + // void MyMethod1(CefOwnPtr obj1) { + // // |obj1| is deleted when MyMethod1() goes out of scope. + // } + // + // void MyMethod2(CefRawPtr obj2) { + // } + static CefOwnPtr Wrap(StructName* s); + + // Retrieve the underlying structure reference from a wrapper instance for + // return back to the other side. Ownership will be passed back to the other + // side and the wrapper will be deleted. For example: + // + // void MyMethod(CefOwnPtr obj) { + // // Ownership of the underlying MyType object is passed to my_method(). + // my_method(MyTypeCToCpp::UnwrapOwn(obj.Pass())); + // // |obj| is now NULL. + // } + static StructName* UnwrapOwn(CefOwnPtr c); + + // Retrieve the underlying structure reference from a wrapper instance for + // return back to the other side. Ownership does not change. For example: + // + // void MyMethod(CefRawPtr obj) { + // // A reference is passed to my_method(). Ownership does not change. + // my_method2(MyTypeCToCpp::UnwrapRaw(obj)); + // } + static StructName* UnwrapRaw(CefRawPtr c); + + // Override delete operator to properly delete the WrapperStruct. + // ~CefCToCppScoped will be called first followed by this method. + static void operator delete(void* ptr); + +#if DCHECK_IS_ON() + // Simple tracking of allocated objects. + static base::AtomicRefCount DebugObjCt; // NOLINT(runtime/int) +#endif + + protected: + CefCToCppScoped() { +#if DCHECK_IS_ON() + base::AtomicRefCountInc(&DebugObjCt); +#endif + } + + virtual ~CefCToCppScoped() { +#if DCHECK_IS_ON() + base::AtomicRefCountDec(&DebugObjCt); +#endif + } + + // If returning the structure across the DLL boundary use Unwrap() instead. + StructName* GetStruct() const { + WrapperStruct* wrapperStruct = GetWrapperStruct(this); + // Verify that the wrapper offset was calculated correctly. + DCHECK_EQ(kWrapperType, wrapperStruct->type_); + return wrapperStruct->struct_; + } + + private: + // Used to associate this wrapper object and the structure reference received + // from the other side. + struct WrapperStruct; + + static WrapperStruct* GetWrapperStruct(const BaseName* obj); + + // Unwrap as the derived type. + static StructName* UnwrapDerivedOwn(CefWrapperType type, + CefOwnPtr c); + static StructName* UnwrapDerivedRaw(CefWrapperType type, + CefRawPtr c); + + static CefWrapperType kWrapperType; + + DISALLOW_COPY_AND_ASSIGN(CefCToCppScoped); +}; + +template +struct CefCToCppScoped::WrapperStruct { + CefWrapperType type_; + StructName* struct_; + ClassName wrapper_; +}; + +template +CefOwnPtr CefCToCppScoped::Wrap( + StructName* s) { + if (!s) + return CefOwnPtr(); + + // Wrap their structure with the CefCToCpp object. + WrapperStruct* wrapperStruct = new WrapperStruct; + wrapperStruct->type_ = kWrapperType; + wrapperStruct->struct_ = s; + + return CefOwnPtr(&wrapperStruct->wrapper_); +} + +template +StructName* CefCToCppScoped::UnwrapOwn( + CefOwnPtr c) { + if (!c.get()) + return NULL; + + WrapperStruct* wrapperStruct = GetWrapperStruct(c.get()); + + // If the type does not match this object then we need to unwrap as the + // derived type. + if (wrapperStruct->type_ != kWrapperType) + return UnwrapDerivedOwn(wrapperStruct->type_, OWN_PASS(c)); + + StructName* orig_struct = wrapperStruct->struct_; + + // We should own the object currently. + cef_base_scoped_t* base = reinterpret_cast(orig_struct); + DCHECK(base && base->del); + + // Don't delete the original object when the wrapper is deleted. + wrapperStruct->struct_ = NULL; + + // Return the original structure. + return orig_struct; + // The wrapper |c| is deleted when this method goes out of scope. +} + +template +StructName* CefCToCppScoped::UnwrapRaw( + CefRawPtr c) { + if (!c) + return NULL; + + WrapperStruct* wrapperStruct = GetWrapperStruct(c); + + // If the type does not match this object then we need to unwrap as the + // derived type. + if (wrapperStruct->type_ != kWrapperType) + return UnwrapDerivedRaw(wrapperStruct->type_, c); + + // Return the original structure. + return wrapperStruct->struct_; +} + +template +void CefCToCppScoped::operator delete( + void* ptr) { + WrapperStruct* wrapperStruct = GetWrapperStruct(static_cast(ptr)); + // Verify that the wrapper offset was calculated correctly. + DCHECK_EQ(kWrapperType, wrapperStruct->type_); + + // May be NULL if UnwrapOwn() was called. + cef_base_scoped_t* base = + reinterpret_cast(wrapperStruct->struct_); + + // If we own the object (base->del != NULL) then notify the other side that + // the object has been deleted. + if (base && base->del) + base->del(base); + + // Delete the wrapper structure without executing ~CefCToCppScoped() an + // additional time. + ::operator delete(wrapperStruct); +} + +template +typename CefCToCppScoped::WrapperStruct* + CefCToCppScoped::GetWrapperStruct( + const BaseName* obj) { + // Offset using the WrapperStruct size instead of individual member sizes to + // avoid problems due to platform/compiler differences in structure padding. + return reinterpret_cast( + reinterpret_cast(const_cast(obj)) - + (sizeof(WrapperStruct) - sizeof(ClassName))); +} + +#endif // CEF_LIBCEF_DLL_CTOCPP_CTOCPP_SCOPED_H_ diff --git a/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc b/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc index 61e94a304..860a0c165 100644 --- a/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc +++ b/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc @@ -48,18 +48,25 @@ bool CefSchemeRegistrarCToCpp::AddCustomScheme(const CefString& scheme_name, CefSchemeRegistrarCToCpp::CefSchemeRegistrarCToCpp() { } -template<> cef_scheme_registrar_t* CefCToCpp::UnwrapDerived( - CefWrapperType type, CefSchemeRegistrar* c) { +template<> cef_scheme_registrar_t* CefCToCppScoped::UnwrapDerivedOwn( + CefWrapperType type, CefOwnPtr c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +template<> cef_scheme_registrar_t* CefCToCppScoped::UnwrapDerivedRaw( + CefWrapperType type, CefRawPtr c) { NOTREACHED() << "Unexpected class type: " << type; return NULL; } #if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; #endif -template<> CefWrapperType CefCToCpp CefWrapperType CefCToCppScoped::kWrapperType = WT_SCHEME_REGISTRAR; diff --git a/libcef_dll/ctocpp/scheme_registrar_ctocpp.h b/libcef_dll/ctocpp/scheme_registrar_ctocpp.h index 73af1dbd5..70cea5431 100644 --- a/libcef_dll/ctocpp/scheme_registrar_ctocpp.h +++ b/libcef_dll/ctocpp/scheme_registrar_ctocpp.h @@ -20,12 +20,12 @@ #include "include/cef_scheme.h" #include "include/capi/cef_scheme_capi.h" -#include "libcef_dll/ctocpp/ctocpp.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. class CefSchemeRegistrarCToCpp - : public CefCToCpp { public: CefSchemeRegistrarCToCpp(); diff --git a/libcef_dll/ctocpp/test/translator_test_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_ctocpp.cc index 3a10a8dd7..3702eda6f 100644 --- a/libcef_dll/ctocpp/test/translator_test_ctocpp.cc +++ b/libcef_dll/ctocpp/test/translator_test_ctocpp.cc @@ -11,11 +11,15 @@ // #include -#include "libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h" -#include "libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h" +#include "libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h" #include "libcef_dll/ctocpp/test/translator_test_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_object_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -632,24 +636,27 @@ size_t CefTranslatorTestCToCpp::GetPointListSize() { return _retval; } -CefRefPtr CefTranslatorTestCToCpp::GetObject(int val) { +CefRefPtr CefTranslatorTestCToCpp::GetRefPtrLibrary( + int val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_object)) + if (CEF_MEMBER_MISSING(_struct, get_ref_ptr_library)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_translator_test_object_t* _retval = _struct->get_object(_struct, + cef_translator_test_ref_ptr_library_t* _retval = _struct->get_ref_ptr_library( + _struct, val); // Return type: refptr_same - return CefTranslatorTestObjectCToCpp::Wrap(_retval); + return CefTranslatorTestRefPtrLibraryCToCpp::Wrap(_retval); } -int CefTranslatorTestCToCpp::SetObject(CefRefPtr val) { +int CefTranslatorTestCToCpp::SetRefPtrLibrary( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_object)) + if (CEF_MEMBER_MISSING(_struct, set_ref_ptr_library)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -660,17 +667,17 @@ int CefTranslatorTestCToCpp::SetObject(CefRefPtr val) { return 0; // Execute - int _retval = _struct->set_object(_struct, - CefTranslatorTestObjectCToCpp::Unwrap(val)); + int _retval = _struct->set_ref_ptr_library(_struct, + CefTranslatorTestRefPtrLibraryCToCpp::Unwrap(val)); // Return type: simple return _retval; } -CefRefPtr CefTranslatorTestCToCpp::SetObjectAndReturn( - CefRefPtr val) { +CefRefPtr CefTranslatorTestCToCpp::SetRefPtrLibraryAndReturn( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_object_and_return)) + if (CEF_MEMBER_MISSING(_struct, set_ref_ptr_library_and_return)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -681,18 +688,18 @@ CefRefPtr CefTranslatorTestCToCpp::SetObjectAndReturn( return NULL; // Execute - cef_translator_test_object_t* _retval = _struct->set_object_and_return( - _struct, - CefTranslatorTestObjectCToCpp::Unwrap(val)); + cef_translator_test_ref_ptr_library_t* _retval = + _struct->set_ref_ptr_library_and_return(_struct, + CefTranslatorTestRefPtrLibraryCToCpp::Unwrap(val)); // Return type: refptr_same - return CefTranslatorTestObjectCToCpp::Wrap(_retval); + return CefTranslatorTestRefPtrLibraryCToCpp::Wrap(_retval); } -int CefTranslatorTestCToCpp::SetChildObject( - CefRefPtr val) { +int CefTranslatorTestCToCpp::SetChildRefPtrLibrary( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_child_object)) + if (CEF_MEMBER_MISSING(_struct, set_child_ref_ptr_library)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -703,17 +710,17 @@ int CefTranslatorTestCToCpp::SetChildObject( return 0; // Execute - int _retval = _struct->set_child_object(_struct, - CefTranslatorTestObjectChildCToCpp::Unwrap(val)); + int _retval = _struct->set_child_ref_ptr_library(_struct, + CefTranslatorTestRefPtrLibraryChildCToCpp::Unwrap(val)); // Return type: simple return _retval; } -CefRefPtr CefTranslatorTestCToCpp::SetChildObjectAndReturnParent( - CefRefPtr val) { +CefRefPtr CefTranslatorTestCToCpp::SetChildRefPtrLibraryAndReturnParent( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_child_object_and_return_parent)) + if (CEF_MEMBER_MISSING(_struct, set_child_ref_ptr_library_and_return_parent)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -724,38 +731,38 @@ CefRefPtr CefTranslatorTestCToCpp::SetChildObjectAndRet return NULL; // Execute - cef_translator_test_object_t* _retval = - _struct->set_child_object_and_return_parent(_struct, - CefTranslatorTestObjectChildCToCpp::Unwrap(val)); + cef_translator_test_ref_ptr_library_t* _retval = + _struct->set_child_ref_ptr_library_and_return_parent(_struct, + CefTranslatorTestRefPtrLibraryChildCToCpp::Unwrap(val)); // Return type: refptr_same - return CefTranslatorTestObjectCToCpp::Wrap(_retval); + return CefTranslatorTestRefPtrLibraryCToCpp::Wrap(_retval); } -bool CefTranslatorTestCToCpp::SetObjectList( - const std::vector>& val, int val1, +bool CefTranslatorTestCToCpp::SetRefPtrLibraryList( + const std::vector>& val, int val1, int val2) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_object_list)) + if (CEF_MEMBER_MISSING(_struct, set_ref_ptr_library_list)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Translate param: val; type: refptr_vec_same_byref_const const size_t valCount = val.size(); - cef_translator_test_object_t** valList = NULL; + cef_translator_test_ref_ptr_library_t** valList = NULL; if (valCount > 0) { - valList = new cef_translator_test_object_t*[valCount]; + valList = new cef_translator_test_ref_ptr_library_t*[valCount]; DCHECK(valList); if (valList) { for (size_t i = 0; i < valCount; ++i) { - valList[i] = CefTranslatorTestObjectCToCpp::Unwrap(val[i]); + valList[i] = CefTranslatorTestRefPtrLibraryCToCpp::Unwrap(val[i]); } } } // Execute - int _retval = _struct->set_object_list(_struct, + int _retval = _struct->set_ref_ptr_library_list(_struct, valCount, valList, val1, @@ -769,33 +776,34 @@ bool CefTranslatorTestCToCpp::SetObjectList( return _retval?true:false; } -bool CefTranslatorTestCToCpp::GetObjectListByRef(ObjectList& val, int val1, - int val2) { +bool CefTranslatorTestCToCpp::GetRefPtrLibraryListByRef(RefPtrLibraryList& val, + int val1, int val2) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_object_list_by_ref)) + if (CEF_MEMBER_MISSING(_struct, get_ref_ptr_library_list_by_ref)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Translate param: val; type: refptr_vec_same_byref size_t valSize = val.size(); - size_t valCount = std::max(GetObjectListSize(), valSize); - cef_translator_test_object_t** valList = NULL; + size_t valCount = std::max(GetRefPtrLibraryListSize(), valSize); + cef_translator_test_ref_ptr_library_t** valList = NULL; if (valCount > 0) { - valList = new cef_translator_test_object_t*[valCount]; + valList = new cef_translator_test_ref_ptr_library_t*[valCount]; DCHECK(valList); if (valList) { - memset(valList, 0, sizeof(cef_translator_test_object_t*)*valCount); + memset(valList, 0, sizeof( + cef_translator_test_ref_ptr_library_t*)*valCount); } if (valList && valSize > 0) { for (size_t i = 0; i < valSize; ++i) { - valList[i] = CefTranslatorTestObjectCToCpp::Unwrap(val[i]); + valList[i] = CefTranslatorTestRefPtrLibraryCToCpp::Unwrap(val[i]); } } } // Execute - int _retval = _struct->get_object_list_by_ref(_struct, + int _retval = _struct->get_ref_ptr_library_list_by_ref(_struct, &valCount, valList, val1, @@ -805,7 +813,7 @@ bool CefTranslatorTestCToCpp::GetObjectListByRef(ObjectList& val, int val1, val.clear(); if (valCount > 0 && valList) { for (size_t i = 0; i < valCount; ++i) { - val.push_back(CefTranslatorTestObjectCToCpp::Wrap(valList[i])); + val.push_back(CefTranslatorTestRefPtrLibraryCToCpp::Wrap(valList[i])); } delete [] valList; } @@ -814,24 +822,24 @@ bool CefTranslatorTestCToCpp::GetObjectListByRef(ObjectList& val, int val1, return _retval?true:false; } -size_t CefTranslatorTestCToCpp::GetObjectListSize() { +size_t CefTranslatorTestCToCpp::GetRefPtrLibraryListSize() { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_object_list_size)) + if (CEF_MEMBER_MISSING(_struct, get_ref_ptr_library_list_size)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - size_t _retval = _struct->get_object_list_size(_struct); + size_t _retval = _struct->get_ref_ptr_library_list_size(_struct); // Return type: simple return _retval; } -int CefTranslatorTestCToCpp::SetHandler( - CefRefPtr val) { +int CefTranslatorTestCToCpp::SetRefPtrClient( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_handler)) + if (CEF_MEMBER_MISSING(_struct, set_ref_ptr_client)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -842,17 +850,17 @@ int CefTranslatorTestCToCpp::SetHandler( return 0; // Execute - int _retval = _struct->set_handler(_struct, - CefTranslatorTestHandlerCppToC::Wrap(val)); + int _retval = _struct->set_ref_ptr_client(_struct, + CefTranslatorTestRefPtrClientCppToC::Wrap(val)); // Return type: simple return _retval; } -CefRefPtr CefTranslatorTestCToCpp::SetHandlerAndReturn( - CefRefPtr val) { +CefRefPtr CefTranslatorTestCToCpp::SetRefPtrClientAndReturn( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_handler_and_return)) + if (CEF_MEMBER_MISSING(_struct, set_ref_ptr_client_and_return)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -863,18 +871,18 @@ CefRefPtr CefTranslatorTestCToCpp::SetHandlerAndReturn return NULL; // Execute - cef_translator_test_handler_t* _retval = _struct->set_handler_and_return( - _struct, - CefTranslatorTestHandlerCppToC::Wrap(val)); + cef_translator_test_ref_ptr_client_t* _retval = + _struct->set_ref_ptr_client_and_return(_struct, + CefTranslatorTestRefPtrClientCppToC::Wrap(val)); // Return type: refptr_diff - return CefTranslatorTestHandlerCppToC::Unwrap(_retval); + return CefTranslatorTestRefPtrClientCppToC::Unwrap(_retval); } -int CefTranslatorTestCToCpp::SetChildHandler( - CefRefPtr val) { +int CefTranslatorTestCToCpp::SetChildRefPtrClient( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_child_handler)) + if (CEF_MEMBER_MISSING(_struct, set_child_ref_ptr_client)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -885,17 +893,17 @@ int CefTranslatorTestCToCpp::SetChildHandler( return 0; // Execute - int _retval = _struct->set_child_handler(_struct, - CefTranslatorTestHandlerChildCppToC::Wrap(val)); + int _retval = _struct->set_child_ref_ptr_client(_struct, + CefTranslatorTestRefPtrClientChildCppToC::Wrap(val)); // Return type: simple return _retval; } -CefRefPtr CefTranslatorTestCToCpp::SetChildHandlerAndReturnParent( - CefRefPtr val) { +CefRefPtr CefTranslatorTestCToCpp::SetChildRefPtrClientAndReturnParent( + CefRefPtr val) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_child_handler_and_return_parent)) + if (CEF_MEMBER_MISSING(_struct, set_child_ref_ptr_client_and_return_parent)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -906,38 +914,38 @@ CefRefPtr CefTranslatorTestCToCpp::SetChildHandlerAndR return NULL; // Execute - cef_translator_test_handler_t* _retval = - _struct->set_child_handler_and_return_parent(_struct, - CefTranslatorTestHandlerChildCppToC::Wrap(val)); + cef_translator_test_ref_ptr_client_t* _retval = + _struct->set_child_ref_ptr_client_and_return_parent(_struct, + CefTranslatorTestRefPtrClientChildCppToC::Wrap(val)); // Return type: refptr_diff - return CefTranslatorTestHandlerCppToC::Unwrap(_retval); + return CefTranslatorTestRefPtrClientCppToC::Unwrap(_retval); } -bool CefTranslatorTestCToCpp::SetHandlerList( - const std::vector>& val, int val1, +bool CefTranslatorTestCToCpp::SetRefPtrClientList( + const std::vector>& val, int val1, int val2) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_handler_list)) + if (CEF_MEMBER_MISSING(_struct, set_ref_ptr_client_list)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Translate param: val; type: refptr_vec_diff_byref_const const size_t valCount = val.size(); - cef_translator_test_handler_t** valList = NULL; + cef_translator_test_ref_ptr_client_t** valList = NULL; if (valCount > 0) { - valList = new cef_translator_test_handler_t*[valCount]; + valList = new cef_translator_test_ref_ptr_client_t*[valCount]; DCHECK(valList); if (valList) { for (size_t i = 0; i < valCount; ++i) { - valList[i] = CefTranslatorTestHandlerCppToC::Wrap(val[i]); + valList[i] = CefTranslatorTestRefPtrClientCppToC::Wrap(val[i]); } } } // Execute - int _retval = _struct->set_handler_list(_struct, + int _retval = _struct->set_ref_ptr_client_list(_struct, valCount, valList, val1, @@ -951,11 +959,11 @@ bool CefTranslatorTestCToCpp::SetHandlerList( return _retval?true:false; } -bool CefTranslatorTestCToCpp::GetHandlerListByRef(HandlerList& val, - CefRefPtr val1, - CefRefPtr val2) { +bool CefTranslatorTestCToCpp::GetRefPtrClientListByRef(RefPtrClientList& val, + CefRefPtr val1, + CefRefPtr val2) { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_handler_list_by_ref)) + if (CEF_MEMBER_MISSING(_struct, get_ref_ptr_client_list_by_ref)) return false; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -971,33 +979,34 @@ bool CefTranslatorTestCToCpp::GetHandlerListByRef(HandlerList& val, // Translate param: val; type: refptr_vec_diff_byref size_t valSize = val.size(); - size_t valCount = std::max(GetObjectListSize(), valSize); - cef_translator_test_handler_t** valList = NULL; + size_t valCount = std::max(GetRefPtrLibraryListSize(), valSize); + cef_translator_test_ref_ptr_client_t** valList = NULL; if (valCount > 0) { - valList = new cef_translator_test_handler_t*[valCount]; + valList = new cef_translator_test_ref_ptr_client_t*[valCount]; DCHECK(valList); if (valList) { - memset(valList, 0, sizeof(cef_translator_test_handler_t*)*valCount); + memset(valList, 0, sizeof( + cef_translator_test_ref_ptr_client_t*)*valCount); } if (valList && valSize > 0) { for (size_t i = 0; i < valSize; ++i) { - valList[i] = CefTranslatorTestHandlerCppToC::Wrap(val[i]); + valList[i] = CefTranslatorTestRefPtrClientCppToC::Wrap(val[i]); } } } // Execute - int _retval = _struct->get_handler_list_by_ref(_struct, + int _retval = _struct->get_ref_ptr_client_list_by_ref(_struct, &valCount, valList, - CefTranslatorTestHandlerCppToC::Wrap(val1), - CefTranslatorTestHandlerCppToC::Wrap(val2)); + CefTranslatorTestRefPtrClientCppToC::Wrap(val1), + CefTranslatorTestRefPtrClientCppToC::Wrap(val2)); // Restore param:val; type: refptr_vec_diff_byref val.clear(); if (valCount > 0 && valList) { for (size_t i = 0; i < valCount; ++i) { - val.push_back(CefTranslatorTestHandlerCppToC::Unwrap(valList[i])); + val.push_back(CefTranslatorTestRefPtrClientCppToC::Unwrap(valList[i])); } delete [] valList; } @@ -1006,20 +1015,381 @@ bool CefTranslatorTestCToCpp::GetHandlerListByRef(HandlerList& val, return _retval?true:false; } -size_t CefTranslatorTestCToCpp::GetHandlerListSize() { +size_t CefTranslatorTestCToCpp::GetRefPtrClientListSize() { cef_translator_test_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_handler_list_size)) + if (CEF_MEMBER_MISSING(_struct, get_ref_ptr_client_list_size)) return 0; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - size_t _retval = _struct->get_handler_list_size(_struct); + size_t _retval = _struct->get_ref_ptr_client_list_size(_struct); // Return type: simple return _retval; } +CefOwnPtr CefTranslatorTestCToCpp::GetOwnPtrLibrary( + int val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_own_ptr_library)) + return CefOwnPtr(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_scoped_library_t* _retval = _struct->get_own_ptr_library( + _struct, + val); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCToCpp::Wrap(_retval); +} + +int CefTranslatorTestCToCpp::SetOwnPtrLibrary( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_own_ptr_library)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_same + DCHECK(val.get()); + if (!val.get()) + return 0; + + // Execute + int _retval = _struct->set_own_ptr_library(_struct, + CefTranslatorTestScopedLibraryCToCpp::UnwrapOwn(OWN_PASS(val))); + + // Return type: simple + return _retval; +} + +CefOwnPtr CefTranslatorTestCToCpp::SetOwnPtrLibraryAndReturn( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_own_ptr_library_and_return)) + return CefOwnPtr(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_same + DCHECK(val.get()); + if (!val.get()) + return CefOwnPtr(); + + // Execute + cef_translator_test_scoped_library_t* _retval = + _struct->set_own_ptr_library_and_return(_struct, + CefTranslatorTestScopedLibraryCToCpp::UnwrapOwn(OWN_PASS(val))); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCToCpp::Wrap(_retval); +} + +int CefTranslatorTestCToCpp::SetChildOwnPtrLibrary( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_child_own_ptr_library)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_same + DCHECK(val.get()); + if (!val.get()) + return 0; + + // Execute + int _retval = _struct->set_child_own_ptr_library(_struct, + CefTranslatorTestScopedLibraryChildCToCpp::UnwrapOwn(OWN_PASS(val))); + + // Return type: simple + return _retval; +} + +CefOwnPtr CefTranslatorTestCToCpp::SetChildOwnPtrLibraryAndReturnParent( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_child_own_ptr_library_and_return_parent)) + return CefOwnPtr(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_same + DCHECK(val.get()); + if (!val.get()) + return CefOwnPtr(); + + // Execute + cef_translator_test_scoped_library_t* _retval = + _struct->set_child_own_ptr_library_and_return_parent(_struct, + CefTranslatorTestScopedLibraryChildCToCpp::UnwrapOwn(OWN_PASS(val))); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCToCpp::Wrap(_retval); +} + +int CefTranslatorTestCToCpp::SetOwnPtrClient( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_own_ptr_client)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_diff + DCHECK(val.get()); + if (!val.get()) + return 0; + + // Execute + int _retval = _struct->set_own_ptr_client(_struct, + CefTranslatorTestScopedClientCppToC::WrapOwn(OWN_PASS(val))); + + // Return type: simple + return _retval; +} + +CefOwnPtr CefTranslatorTestCToCpp::SetOwnPtrClientAndReturn( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_own_ptr_client_and_return)) + return CefOwnPtr(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_diff + DCHECK(val.get()); + if (!val.get()) + return CefOwnPtr(); + + // Execute + cef_translator_test_scoped_client_t* _retval = + _struct->set_own_ptr_client_and_return(_struct, + CefTranslatorTestScopedClientCppToC::WrapOwn(OWN_PASS(val))); + + // Return type: ownptr_diff + return CefTranslatorTestScopedClientCppToC::UnwrapOwn(_retval); +} + +int CefTranslatorTestCToCpp::SetChildOwnPtrClient( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_child_own_ptr_client)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_diff + DCHECK(val.get()); + if (!val.get()) + return 0; + + // Execute + int _retval = _struct->set_child_own_ptr_client(_struct, + CefTranslatorTestScopedClientChildCppToC::WrapOwn(OWN_PASS(val))); + + // Return type: simple + return _retval; +} + +CefOwnPtr CefTranslatorTestCToCpp::SetChildOwnPtrClientAndReturnParent( + CefOwnPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_child_own_ptr_client_and_return_parent)) + return CefOwnPtr(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: ownptr_diff + DCHECK(val.get()); + if (!val.get()) + return CefOwnPtr(); + + // Execute + cef_translator_test_scoped_client_t* _retval = + _struct->set_child_own_ptr_client_and_return_parent(_struct, + CefTranslatorTestScopedClientChildCppToC::WrapOwn(OWN_PASS(val))); + + // Return type: ownptr_diff + return CefTranslatorTestScopedClientCppToC::UnwrapOwn(_retval); +} + +int CefTranslatorTestCToCpp::SetRawPtrLibrary( + CefRawPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_raw_ptr_library)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: rawptr_same + DCHECK(val); + if (!val) + return 0; + + // Execute + int _retval = _struct->set_raw_ptr_library(_struct, + CefTranslatorTestScopedLibraryCToCpp::UnwrapRaw(val)); + + // Return type: simple + return _retval; +} + +int CefTranslatorTestCToCpp::SetChildRawPtrLibrary( + CefRawPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_child_raw_ptr_library)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: rawptr_same + DCHECK(val); + if (!val) + return 0; + + // Execute + int _retval = _struct->set_child_raw_ptr_library(_struct, + CefTranslatorTestScopedLibraryChildCToCpp::UnwrapRaw(val)); + + // Return type: simple + return _retval; +} + +bool CefTranslatorTestCToCpp::SetRawPtrLibraryList( + const std::vector>& val, int val1, + int val2) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_raw_ptr_library_list)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: val; type: rawptr_vec_same_byref_const + const size_t valCount = val.size(); + cef_translator_test_scoped_library_t** valList = NULL; + if (valCount > 0) { + valList = new cef_translator_test_scoped_library_t*[valCount]; + DCHECK(valList); + if (valList) { + for (size_t i = 0; i < valCount; ++i) { + valList[i] = CefTranslatorTestScopedLibraryCToCpp::UnwrapRaw(val[i]); + } + } + } + + // Execute + int _retval = _struct->set_raw_ptr_library_list(_struct, + valCount, + valList, + val1, + val2); + + // Restore param:val; type: rawptr_vec_same_byref_const + if (valList) + delete [] valList; + + // Return type: bool + return _retval?true:false; +} + +int CefTranslatorTestCToCpp::SetRawPtrClient( + CefRawPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_raw_ptr_client)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: rawptr_diff + DCHECK(val); + if (!val) + return 0; + + // Translate param: val; type: rawptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientCppToC::WrapRaw(val)); + + // Execute + int _retval = _struct->set_raw_ptr_client(_struct, + valPtr->GetStruct()); + + // Return type: simple + return _retval; +} + +int CefTranslatorTestCToCpp::SetChildRawPtrClient( + CefRawPtr val) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_child_raw_ptr_client)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: val; type: rawptr_diff + DCHECK(val); + if (!val) + return 0; + + // Translate param: val; type: rawptr_diff + CefOwnPtr valPtr( + CefTranslatorTestScopedClientChildCppToC::WrapRaw(val)); + + // Execute + int _retval = _struct->set_child_raw_ptr_client(_struct, + valPtr->GetStruct()); + + // Return type: simple + return _retval; +} + +bool CefTranslatorTestCToCpp::SetRawPtrClientList( + const std::vector>& val, int val1, + int val2) { + cef_translator_test_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_raw_ptr_client_list)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: val; type: rawptr_vec_diff_byref_const + const size_t valCount = val.size(); + cef_translator_test_scoped_client_t** valList = NULL; + if (valCount > 0) { + valList = new cef_translator_test_scoped_client_t*[valCount]; + DCHECK(valList); + if (valList) { + for (size_t i = 0; i < valCount; ++i) { + valList[i] = CefTranslatorTestScopedClientCppToC::WrapRaw( + val[i]).release()->GetStruct(); + } + } + } + + // Execute + int _retval = _struct->set_raw_ptr_client_list(_struct, + valCount, + valList, + val1, + val2); + + // Restore param:val; type: rawptr_vec_diff_byref_const + if (valCount > 0) { + for (size_t i = 0; i < valCount; ++i) { + delete CefTranslatorTestScopedClientCppToC::GetWrapper(valList[i]); + } + } + if (valList) + delete [] valList; + + // Return type: bool + return _retval?true:false; +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/test/translator_test_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_ctocpp.h index 4a0393b74..cc2fe198b 100644 --- a/libcef_dll/ctocpp/test/translator_test_ctocpp.h +++ b/libcef_dll/ctocpp/test/translator_test_ctocpp.h @@ -64,30 +64,61 @@ class CefTranslatorTestCToCpp bool SetPointList(const std::vector& val) OVERRIDE; bool GetPointListByRef(PointList& val) OVERRIDE; size_t GetPointListSize() OVERRIDE; - CefRefPtr GetObject(int val) OVERRIDE; - int SetObject(CefRefPtr val) OVERRIDE; - CefRefPtr SetObjectAndReturn( - CefRefPtr val) OVERRIDE; - int SetChildObject(CefRefPtr val) OVERRIDE; - CefRefPtr SetChildObjectAndReturnParent( - CefRefPtr val) OVERRIDE; - bool SetObjectList(const std::vector>& val, + CefRefPtr GetRefPtrLibrary(int val) OVERRIDE; + int SetRefPtrLibrary(CefRefPtr val) OVERRIDE; + CefRefPtr SetRefPtrLibraryAndReturn( + CefRefPtr val) OVERRIDE; + int SetChildRefPtrLibrary( + CefRefPtr val) OVERRIDE; + CefRefPtr SetChildRefPtrLibraryAndReturnParent( + CefRefPtr val) OVERRIDE; + bool SetRefPtrLibraryList( + const std::vector>& val, int val1, int val2) OVERRIDE; - bool GetObjectListByRef(ObjectList& val, int val1, int val2) OVERRIDE; - size_t GetObjectListSize() OVERRIDE; - int SetHandler(CefRefPtr val) OVERRIDE; - CefRefPtr SetHandlerAndReturn( - CefRefPtr val) OVERRIDE; - int SetChildHandler(CefRefPtr val) OVERRIDE; - CefRefPtr SetChildHandlerAndReturnParent( - CefRefPtr val) OVERRIDE; - bool SetHandlerList( - const std::vector>& val, int val1, + bool GetRefPtrLibraryListByRef(RefPtrLibraryList& val, int val1, int val2) OVERRIDE; - bool GetHandlerListByRef(HandlerList& val, - CefRefPtr val1, - CefRefPtr val2) OVERRIDE; - size_t GetHandlerListSize() OVERRIDE; + size_t GetRefPtrLibraryListSize() OVERRIDE; + int SetRefPtrClient(CefRefPtr val) OVERRIDE; + CefRefPtr SetRefPtrClientAndReturn( + CefRefPtr val) OVERRIDE; + int SetChildRefPtrClient( + CefRefPtr val) OVERRIDE; + CefRefPtr SetChildRefPtrClientAndReturnParent( + CefRefPtr val) OVERRIDE; + bool SetRefPtrClientList( + const std::vector>& val, + int val1, int val2) OVERRIDE; + bool GetRefPtrClientListByRef(RefPtrClientList& val, + CefRefPtr val1, + CefRefPtr val2) OVERRIDE; + size_t GetRefPtrClientListSize() OVERRIDE; + CefOwnPtr GetOwnPtrLibrary(int val) OVERRIDE; + int SetOwnPtrLibrary(CefOwnPtr val) OVERRIDE; + CefOwnPtr SetOwnPtrLibraryAndReturn( + CefOwnPtr val) OVERRIDE; + int SetChildOwnPtrLibrary( + CefOwnPtr val) OVERRIDE; + CefOwnPtr SetChildOwnPtrLibraryAndReturnParent( + CefOwnPtr val) OVERRIDE; + int SetOwnPtrClient(CefOwnPtr val) OVERRIDE; + CefOwnPtr SetOwnPtrClientAndReturn( + CefOwnPtr val) OVERRIDE; + int SetChildOwnPtrClient( + CefOwnPtr val) OVERRIDE; + CefOwnPtr SetChildOwnPtrClientAndReturnParent( + CefOwnPtr val) OVERRIDE; + int SetRawPtrLibrary(CefRawPtr val) OVERRIDE; + int SetChildRawPtrLibrary( + CefRawPtr val) OVERRIDE; + bool SetRawPtrLibraryList( + const std::vector>& val, + int val1, int val2) OVERRIDE; + int SetRawPtrClient(CefRawPtr val) OVERRIDE; + int SetChildRawPtrClient( + CefRawPtr val) OVERRIDE; + bool SetRawPtrClientList( + const std::vector>& val, + int val1, int val2) OVERRIDE; }; #endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_handler_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_handler_ctocpp.cc deleted file mode 100644 index ff28b28fa..000000000 --- a/libcef_dll/ctocpp/test/translator_test_handler_ctocpp.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h" - - -// VIRTUAL METHODS - Body may be edited by hand. - -int CefTranslatorTestHandlerCToCpp::GetValue() { - cef_translator_test_handler_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_value(_struct); - - // Return type: simple - return _retval; -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestHandlerCToCpp::CefTranslatorTestHandlerCToCpp() { -} - -template<> cef_translator_test_handler_t* CefCToCpp::UnwrapDerived( - CefWrapperType type, CefTranslatorTestHandler* c) { - if (type == WT_TRANSLATOR_TEST_HANDLER_CHILD) { - return reinterpret_cast( - CefTranslatorTestHandlerChildCToCpp::Unwrap( - reinterpret_cast(c))); - } - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCToCpp::kWrapperType = - WT_TRANSLATOR_TEST_HANDLER; diff --git a/libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.cc deleted file mode 100644 index c8ab57e02..000000000 --- a/libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.cc +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h" - - -// STATIC METHODS - Body may be edited by hand. - -CefRefPtr CefTranslatorTestObjectChildChild::Create( - int value, int other_value, int other_other_value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_translator_test_object_child_child_t* _retval = - cef_translator_test_object_child_child_create( - value, - other_value, - other_other_value); - - // Return type: refptr_same - return CefTranslatorTestObjectChildChildCToCpp::Wrap(_retval); -} - - -// VIRTUAL METHODS - Body may be edited by hand. - -int CefTranslatorTestObjectChildChildCToCpp::GetOtherOtherValue() { - cef_translator_test_object_child_child_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_other_other_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_other_other_value(_struct); - - // Return type: simple - return _retval; -} - -void CefTranslatorTestObjectChildChildCToCpp::SetOtherOtherValue(int value) { - cef_translator_test_object_child_child_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_other_other_value)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - _struct->set_other_other_value(_struct, - value); -} - -int CefTranslatorTestObjectChildChildCToCpp::GetOtherValue() { - cef_translator_test_object_child_t* _struct = - reinterpret_cast(GetStruct()); - if (CEF_MEMBER_MISSING(_struct, get_other_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_other_value(_struct); - - // Return type: simple - return _retval; -} - -void CefTranslatorTestObjectChildChildCToCpp::SetOtherValue(int value) { - cef_translator_test_object_child_t* _struct = - reinterpret_cast(GetStruct()); - if (CEF_MEMBER_MISSING(_struct, set_other_value)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - _struct->set_other_value(_struct, - value); -} - -int CefTranslatorTestObjectChildChildCToCpp::GetValue() { - cef_translator_test_object_t* _struct = - reinterpret_cast(GetStruct()); - if (CEF_MEMBER_MISSING(_struct, get_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_value(_struct); - - // Return type: simple - return _retval; -} - -void CefTranslatorTestObjectChildChildCToCpp::SetValue(int value) { - cef_translator_test_object_t* _struct = - reinterpret_cast(GetStruct()); - if (CEF_MEMBER_MISSING(_struct, set_value)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - _struct->set_value(_struct, - value); -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestObjectChildChildCToCpp::CefTranslatorTestObjectChildChildCToCpp( - ) { -} - -template<> cef_translator_test_object_child_child_t* CefCToCpp::UnwrapDerived( - CefWrapperType type, CefTranslatorTestObjectChildChild* c) { - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCToCpp::kWrapperType = - WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.cc deleted file mode 100644 index 1da2ca4a3..000000000 --- a/libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h" - - -// STATIC METHODS - Body may be edited by hand. - -CefRefPtr CefTranslatorTestObjectChild::Create( - int value, int other_value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_translator_test_object_child_t* _retval = - cef_translator_test_object_child_create( - value, - other_value); - - // Return type: refptr_same - return CefTranslatorTestObjectChildCToCpp::Wrap(_retval); -} - - -// VIRTUAL METHODS - Body may be edited by hand. - -int CefTranslatorTestObjectChildCToCpp::GetOtherValue() { - cef_translator_test_object_child_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_other_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_other_value(_struct); - - // Return type: simple - return _retval; -} - -void CefTranslatorTestObjectChildCToCpp::SetOtherValue(int value) { - cef_translator_test_object_child_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_other_value)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - _struct->set_other_value(_struct, - value); -} - -int CefTranslatorTestObjectChildCToCpp::GetValue() { - cef_translator_test_object_t* _struct = - reinterpret_cast(GetStruct()); - if (CEF_MEMBER_MISSING(_struct, get_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_value(_struct); - - // Return type: simple - return _retval; -} - -void CefTranslatorTestObjectChildCToCpp::SetValue(int value) { - cef_translator_test_object_t* _struct = - reinterpret_cast(GetStruct()); - if (CEF_MEMBER_MISSING(_struct, set_value)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - _struct->set_value(_struct, - value); -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestObjectChildCToCpp::CefTranslatorTestObjectChildCToCpp() { -} - -template<> cef_translator_test_object_child_t* CefCToCpp::UnwrapDerived(CefWrapperType type, - CefTranslatorTestObjectChild* c) { - if (type == WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD) { - return reinterpret_cast( - CefTranslatorTestObjectChildChildCToCpp::Unwrap( - reinterpret_cast(c))); - } - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCToCpp::kWrapperType = - WT_TRANSLATOR_TEST_OBJECT_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_object_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_object_ctocpp.cc deleted file mode 100644 index 6c3302097..000000000 --- a/libcef_dll/ctocpp/test/translator_test_object_ctocpp.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2017 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. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/ctocpp/test/translator_test_object_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h" -#include "libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h" - - -// STATIC METHODS - Body may be edited by hand. - -CefRefPtr CefTranslatorTestObject::Create(int value) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_translator_test_object_t* _retval = cef_translator_test_object_create( - value); - - // Return type: refptr_same - return CefTranslatorTestObjectCToCpp::Wrap(_retval); -} - - -// VIRTUAL METHODS - Body may be edited by hand. - -int CefTranslatorTestObjectCToCpp::GetValue() { - cef_translator_test_object_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_value)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->get_value(_struct); - - // Return type: simple - return _retval; -} - -void CefTranslatorTestObjectCToCpp::SetValue(int value) { - cef_translator_test_object_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_value)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - _struct->set_value(_struct, - value); -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefTranslatorTestObjectCToCpp::CefTranslatorTestObjectCToCpp() { -} - -template<> cef_translator_test_object_t* CefCToCpp::UnwrapDerived( - CefWrapperType type, CefTranslatorTestObject* c) { - if (type == WT_TRANSLATOR_TEST_OBJECT_CHILD) { - return reinterpret_cast( - CefTranslatorTestObjectChildCToCpp::Unwrap( - reinterpret_cast(c))); - } - if (type == WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD) { - return reinterpret_cast( - CefTranslatorTestObjectChildChildCToCpp::Unwrap( - reinterpret_cast(c))); - } - NOTREACHED() << "Unexpected class type: " << type; - return NULL; -} - -#if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; -#endif - -template<> CefWrapperType CefCToCpp::kWrapperType = - WT_TRANSLATOR_TEST_OBJECT; diff --git a/libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.cc similarity index 52% rename from libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.cc rename to libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.cc index 83f69edd4..5aac818bd 100644 --- a/libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.cc +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.cc @@ -10,13 +10,13 @@ // for more information. // -#include "libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h" // VIRTUAL METHODS - Body may be edited by hand. -int CefTranslatorTestHandlerChildCToCpp::GetOtherValue() { - cef_translator_test_handler_child_t* _struct = GetStruct(); +int CefTranslatorTestRefPtrClientChildCToCpp::GetOtherValue() { + cef_translator_test_ref_ptr_client_child_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_other_value)) return 0; @@ -29,9 +29,9 @@ int CefTranslatorTestHandlerChildCToCpp::GetOtherValue() { return _retval; } -int CefTranslatorTestHandlerChildCToCpp::GetValue() { - cef_translator_test_handler_t* _struct = - reinterpret_cast(GetStruct()); +int CefTranslatorTestRefPtrClientChildCToCpp::GetValue() { + cef_translator_test_ref_ptr_client_t* _struct = + reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_value)) return 0; @@ -47,24 +47,25 @@ int CefTranslatorTestHandlerChildCToCpp::GetValue() { // CONSTRUCTOR - Do not edit by hand. -CefTranslatorTestHandlerChildCToCpp::CefTranslatorTestHandlerChildCToCpp() { +CefTranslatorTestRefPtrClientChildCToCpp::CefTranslatorTestRefPtrClientChildCToCpp( + ) { } -template<> cef_translator_test_handler_child_t* CefCToCpp::UnwrapDerived(CefWrapperType type, - CefTranslatorTestHandlerChild* c) { +template<> cef_translator_test_ref_ptr_client_child_t* CefCToCpp::UnwrapDerived( + CefWrapperType type, CefTranslatorTestRefPtrClientChild* c) { NOTREACHED() << "Unexpected class type: " << type; return NULL; } #if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; #endif -template<> CefWrapperType CefCToCpp::kWrapperType = - WT_TRANSLATOR_TEST_HANDLER_CHILD; +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h similarity index 61% rename from libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h rename to libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h index beba15046..0dd9e5cb1 100644 --- a/libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_HANDLER_CHILD_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_HANDLER_CHILD_CTOCPP_H_ +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD_CTOCPP_H_ #pragma once #if !defined(BUILDING_CEF_SHARED) @@ -24,17 +24,18 @@ // Wrap a C structure with a C++ class. // This class may be instantiated and accessed DLL-side only. -class CefTranslatorTestHandlerChildCToCpp - : public CefCToCpp { +class CefTranslatorTestRefPtrClientChildCToCpp + : public CefCToCpp { public: - CefTranslatorTestHandlerChildCToCpp(); + CefTranslatorTestRefPtrClientChildCToCpp(); - // CefTranslatorTestHandlerChild methods. + // CefTranslatorTestRefPtrClientChild methods. int GetOtherValue() override; - // CefTranslatorTestHandler methods. + // CefTranslatorTestRefPtrClient methods. int GetValue() override; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_HANDLER_CHILD_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.cc new file mode 100644 index 000000000..e1a7ca770 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.cc @@ -0,0 +1,61 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestRefPtrClientCToCpp::GetValue() { + cef_translator_test_ref_ptr_client_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrClientCToCpp::CefTranslatorTestRefPtrClientCToCpp() { +} + +template<> cef_translator_test_ref_ptr_client_t* CefCToCpp::UnwrapDerived(CefWrapperType type, + CefTranslatorTestRefPtrClient* c) { + if (type == WT_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD) { + return reinterpret_cast( + CefTranslatorTestRefPtrClientChildCToCpp::Unwrap( + reinterpret_cast(c))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_CLIENT; diff --git a/libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h similarity index 64% rename from libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h rename to libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h index 36e16d015..83ffc852d 100644 --- a/libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_HANDLER_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_HANDLER_CTOCPP_H_ +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CTOCPP_H_ #pragma once #if !defined(BUILDING_CEF_SHARED) @@ -24,14 +24,14 @@ // Wrap a C structure with a C++ class. // This class may be instantiated and accessed DLL-side only. -class CefTranslatorTestHandlerCToCpp - : public CefCToCpp { +class CefTranslatorTestRefPtrClientCToCpp + : public CefCToCpp { public: - CefTranslatorTestHandlerCToCpp(); + CefTranslatorTestRefPtrClientCToCpp(); - // CefTranslatorTestHandler methods. + // CefTranslatorTestRefPtrClient methods. int GetValue() override; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_HANDLER_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_CLIENT_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.cc new file mode 100644 index 000000000..9bcab59d1 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.cc @@ -0,0 +1,145 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefTranslatorTestRefPtrLibraryChildChild::Create( + int value, int other_value, int other_other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_ref_ptr_library_child_child_t* _retval = + cef_translator_test_ref_ptr_library_child_child_create( + value, + other_value, + other_other_value); + + // Return type: refptr_same + return CefTranslatorTestRefPtrLibraryChildChildCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestRefPtrLibraryChildChildCToCpp::GetOtherOtherValue() { + cef_translator_test_ref_ptr_library_child_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_other_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_other_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestRefPtrLibraryChildChildCToCpp::SetOtherOtherValue( + int value) { + cef_translator_test_ref_ptr_library_child_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_other_other_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_other_other_value(_struct, + value); +} + +int CefTranslatorTestRefPtrLibraryChildChildCToCpp::GetOtherValue() { + cef_translator_test_ref_ptr_library_child_t* _struct = + reinterpret_cast(GetStruct( + )); + if (CEF_MEMBER_MISSING(_struct, get_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestRefPtrLibraryChildChildCToCpp::SetOtherValue(int value) { + cef_translator_test_ref_ptr_library_child_t* _struct = + reinterpret_cast(GetStruct( + )); + if (CEF_MEMBER_MISSING(_struct, set_other_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_other_value(_struct, + value); +} + +int CefTranslatorTestRefPtrLibraryChildChildCToCpp::GetValue() { + cef_translator_test_ref_ptr_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestRefPtrLibraryChildChildCToCpp::SetValue(int value) { + cef_translator_test_ref_ptr_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_value(_struct, + value); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrLibraryChildChildCToCpp::CefTranslatorTestRefPtrLibraryChildChildCToCpp( + ) { +} + +template<> cef_translator_test_ref_ptr_library_child_child_t* CefCToCpp::UnwrapDerived( + CefWrapperType type, CefTranslatorTestRefPtrLibraryChildChild* c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h similarity index 61% rename from libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h rename to libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h index b8f3b9309..eefaf1232 100644 --- a/libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CHILD_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CHILD_CTOCPP_H_ +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD_CTOCPP_H_ #pragma once #if !defined(WRAPPING_CEF_SHARED) @@ -24,24 +24,24 @@ // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. -class CefTranslatorTestObjectChildChildCToCpp - : public CefCToCpp { +class CefTranslatorTestRefPtrLibraryChildChildCToCpp + : public CefCToCpp { public: - CefTranslatorTestObjectChildChildCToCpp(); + CefTranslatorTestRefPtrLibraryChildChildCToCpp(); - // CefTranslatorTestObjectChildChild methods. + // CefTranslatorTestRefPtrLibraryChildChild methods. int GetOtherOtherValue() OVERRIDE; void SetOtherOtherValue(int value) OVERRIDE; - // CefTranslatorTestObjectChild methods. + // CefTranslatorTestRefPtrLibraryChild methods. int GetOtherValue() OVERRIDE; void SetOtherValue(int value) OVERRIDE; - // CefTranslatorTestObject methods. + // CefTranslatorTestRefPtrLibrary methods. int GetValue() OVERRIDE; void SetValue(int value) OVERRIDE; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CHILD_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.cc new file mode 100644 index 000000000..c52751c55 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.cc @@ -0,0 +1,119 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefTranslatorTestRefPtrLibraryChild::Create( + int value, int other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_ref_ptr_library_child_t* _retval = + cef_translator_test_ref_ptr_library_child_create( + value, + other_value); + + // Return type: refptr_same + return CefTranslatorTestRefPtrLibraryChildCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestRefPtrLibraryChildCToCpp::GetOtherValue() { + cef_translator_test_ref_ptr_library_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestRefPtrLibraryChildCToCpp::SetOtherValue(int value) { + cef_translator_test_ref_ptr_library_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_other_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_other_value(_struct, + value); +} + +int CefTranslatorTestRefPtrLibraryChildCToCpp::GetValue() { + cef_translator_test_ref_ptr_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestRefPtrLibraryChildCToCpp::SetValue(int value) { + cef_translator_test_ref_ptr_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_value(_struct, + value); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrLibraryChildCToCpp::CefTranslatorTestRefPtrLibraryChildCToCpp( + ) { +} + +template<> cef_translator_test_ref_ptr_library_child_t* CefCToCpp::UnwrapDerived( + CefWrapperType type, CefTranslatorTestRefPtrLibraryChild* c) { + if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD) { + return reinterpret_cast( + CefTranslatorTestRefPtrLibraryChildChildCToCpp::Unwrap( + reinterpret_cast(c))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h similarity index 62% rename from libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h rename to libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h index af47c9794..3d2d8d977 100644 --- a/libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CTOCPP_H_ +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CTOCPP_H_ #pragma once #if !defined(WRAPPING_CEF_SHARED) @@ -24,19 +24,20 @@ // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. -class CefTranslatorTestObjectChildCToCpp - : public CefCToCpp { +class CefTranslatorTestRefPtrLibraryChildCToCpp + : public CefCToCpp { public: - CefTranslatorTestObjectChildCToCpp(); + CefTranslatorTestRefPtrLibraryChildCToCpp(); - // CefTranslatorTestObjectChild methods. + // CefTranslatorTestRefPtrLibraryChild methods. int GetOtherValue() OVERRIDE; void SetOtherValue(int value) OVERRIDE; - // CefTranslatorTestObject methods. + // CefTranslatorTestRefPtrLibrary methods. int GetValue() OVERRIDE; void SetValue(int value) OVERRIDE; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CHILD_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.cc new file mode 100644 index 000000000..c39b0504c --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.cc @@ -0,0 +1,95 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefTranslatorTestRefPtrLibrary::Create( + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_ref_ptr_library_t* _retval = + cef_translator_test_ref_ptr_library_create( + value); + + // Return type: refptr_same + return CefTranslatorTestRefPtrLibraryCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestRefPtrLibraryCToCpp::GetValue() { + cef_translator_test_ref_ptr_library_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestRefPtrLibraryCToCpp::SetValue(int value) { + cef_translator_test_ref_ptr_library_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_value(_struct, + value); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestRefPtrLibraryCToCpp::CefTranslatorTestRefPtrLibraryCToCpp() { +} + +template<> cef_translator_test_ref_ptr_library_t* CefCToCpp::UnwrapDerived(CefWrapperType type, + CefTranslatorTestRefPtrLibrary* c) { + if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD) { + return reinterpret_cast( + CefTranslatorTestRefPtrLibraryChildCToCpp::Unwrap( + reinterpret_cast(c))); + } + if (type == WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD) { + return reinterpret_cast( + CefTranslatorTestRefPtrLibraryChildChildCToCpp::Unwrap( + reinterpret_cast(c))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY; diff --git a/libcef_dll/ctocpp/test/translator_test_object_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h similarity index 65% rename from libcef_dll/ctocpp/test/translator_test_object_ctocpp.h rename to libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h index 797604b82..fe11d6e3b 100644 --- a/libcef_dll/ctocpp/test/translator_test_object_ctocpp.h +++ b/libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CTOCPP_H_ +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CTOCPP_H_ #pragma once #if !defined(WRAPPING_CEF_SHARED) @@ -24,15 +24,16 @@ // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. -class CefTranslatorTestObjectCToCpp - : public CefCToCpp { +class CefTranslatorTestRefPtrLibraryCToCpp + : public CefCToCpp { public: - CefTranslatorTestObjectCToCpp(); + CefTranslatorTestRefPtrLibraryCToCpp(); - // CefTranslatorTestObject methods. + // CefTranslatorTestRefPtrLibrary methods. int GetValue() OVERRIDE; void SetValue(int value) OVERRIDE; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_OBJECT_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_REF_PTR_LIBRARY_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.cc new file mode 100644 index 000000000..21da945f6 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestScopedClientChildCToCpp::GetOtherValue() { + cef_translator_test_scoped_client_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_value(_struct); + + // Return type: simple + return _retval; +} + +int CefTranslatorTestScopedClientChildCToCpp::GetValue() { + cef_translator_test_scoped_client_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedClientChildCToCpp::CefTranslatorTestScopedClientChildCToCpp( + ) { +} + +template<> cef_translator_test_scoped_client_child_t* CefCToCppScoped::UnwrapDerivedOwn( + CefWrapperType type, CefOwnPtr c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +template<> cef_translator_test_scoped_client_child_t* CefCToCppScoped::UnwrapDerivedRaw( + CefWrapperType type, CefRawPtr c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCppScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h new file mode 100644 index 000000000..59dc1bb5e --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h @@ -0,0 +1,41 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD_CTOCPP_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefTranslatorTestScopedClientChildCToCpp + : public CefCToCppScoped { + public: + CefTranslatorTestScopedClientChildCToCpp(); + + // CefTranslatorTestScopedClientChild methods. + int GetOtherValue() override; + + // CefTranslatorTestScopedClient methods. + int GetValue() override; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.cc new file mode 100644 index 000000000..7908e4a4f --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.cc @@ -0,0 +1,76 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestScopedClientCToCpp::GetValue() { + cef_translator_test_scoped_client_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedClientCToCpp::CefTranslatorTestScopedClientCToCpp() { +} + +template<> cef_translator_test_scoped_client_t* CefCToCppScoped::UnwrapDerivedOwn(CefWrapperType type, + CefOwnPtr c) { + if (type == WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedClientChildCToCpp::UnwrapOwn( + CefOwnPtr( + reinterpret_cast(c.release())))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +template<> cef_translator_test_scoped_client_t* CefCToCppScoped::UnwrapDerivedRaw(CefWrapperType type, + CefRawPtr c) { + if (type == WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedClientChildCToCpp::UnwrapRaw( + CefRawPtr( + reinterpret_cast(c)))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCppScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_CLIENT; diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h new file mode 100644 index 000000000..a77accd17 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h @@ -0,0 +1,37 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CTOCPP_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefTranslatorTestScopedClientCToCpp + : public CefCToCppScoped { + public: + CefTranslatorTestScopedClientCToCpp(); + + // CefTranslatorTestScopedClient methods. + int GetValue() override; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_CLIENT_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.cc new file mode 100644 index 000000000..8401e202f --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.cc @@ -0,0 +1,155 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefOwnPtr CefTranslatorTestScopedLibraryChildChild::Create( + int value, int other_value, int other_other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_scoped_library_child_child_t* _retval = + cef_translator_test_scoped_library_child_child_create( + value, + other_value, + other_other_value); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryChildChildCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestScopedLibraryChildChildCToCpp::GetOtherOtherValue() { + cef_translator_test_scoped_library_child_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_other_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_other_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestScopedLibraryChildChildCToCpp::SetOtherOtherValue( + int value) { + cef_translator_test_scoped_library_child_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_other_other_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_other_other_value(_struct, + value); +} + +int CefTranslatorTestScopedLibraryChildChildCToCpp::GetOtherValue() { + cef_translator_test_scoped_library_child_t* _struct = + reinterpret_cast(GetStruct( + )); + if (CEF_MEMBER_MISSING(_struct, get_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestScopedLibraryChildChildCToCpp::SetOtherValue(int value) { + cef_translator_test_scoped_library_child_t* _struct = + reinterpret_cast(GetStruct( + )); + if (CEF_MEMBER_MISSING(_struct, set_other_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_other_value(_struct, + value); +} + +int CefTranslatorTestScopedLibraryChildChildCToCpp::GetValue() { + cef_translator_test_scoped_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestScopedLibraryChildChildCToCpp::SetValue(int value) { + cef_translator_test_scoped_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_value(_struct, + value); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedLibraryChildChildCToCpp::CefTranslatorTestScopedLibraryChildChildCToCpp( + ) { +} + +template<> cef_translator_test_scoped_library_child_child_t* CefCToCppScoped::UnwrapDerivedOwn( + CefWrapperType type, + CefOwnPtr c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +template<> cef_translator_test_scoped_library_child_child_t* CefCToCppScoped::UnwrapDerivedRaw( + CefWrapperType type, + CefRawPtr c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCppScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h new file mode 100644 index 000000000..e0988b19f --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h @@ -0,0 +1,47 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD_CTOCPP_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefTranslatorTestScopedLibraryChildChildCToCpp + : public CefCToCppScoped { + public: + CefTranslatorTestScopedLibraryChildChildCToCpp(); + + // CefTranslatorTestScopedLibraryChildChild methods. + int GetOtherOtherValue() OVERRIDE; + void SetOtherOtherValue(int value) OVERRIDE; + + // CefTranslatorTestScopedLibraryChild methods. + int GetOtherValue() OVERRIDE; + void SetOtherValue(int value) OVERRIDE; + + // CefTranslatorTestScopedLibrary methods. + int GetValue() OVERRIDE; + void SetValue(int value) OVERRIDE; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.cc new file mode 100644 index 000000000..af2fd8bcb --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.cc @@ -0,0 +1,135 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefOwnPtr CefTranslatorTestScopedLibraryChild::Create( + int value, int other_value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_scoped_library_child_t* _retval = + cef_translator_test_scoped_library_child_create( + value, + other_value); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryChildCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestScopedLibraryChildCToCpp::GetOtherValue() { + cef_translator_test_scoped_library_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_other_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_other_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestScopedLibraryChildCToCpp::SetOtherValue(int value) { + cef_translator_test_scoped_library_child_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_other_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_other_value(_struct, + value); +} + +int CefTranslatorTestScopedLibraryChildCToCpp::GetValue() { + cef_translator_test_scoped_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestScopedLibraryChildCToCpp::SetValue(int value) { + cef_translator_test_scoped_library_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_value(_struct, + value); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedLibraryChildCToCpp::CefTranslatorTestScopedLibraryChildCToCpp( + ) { +} + +template<> cef_translator_test_scoped_library_child_t* CefCToCppScoped::UnwrapDerivedOwn( + CefWrapperType type, CefOwnPtr c) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedLibraryChildChildCToCpp::UnwrapOwn( + CefOwnPtr( + reinterpret_cast(c.release( + ))))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +template<> cef_translator_test_scoped_library_child_t* CefCToCppScoped::UnwrapDerivedRaw( + CefWrapperType type, CefRawPtr c) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedLibraryChildChildCToCpp::UnwrapRaw( + CefRawPtr( + reinterpret_cast(c)))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCppScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD; diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h new file mode 100644 index 000000000..39beaa77a --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CTOCPP_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefTranslatorTestScopedLibraryChildCToCpp + : public CefCToCppScoped { + public: + CefTranslatorTestScopedLibraryChildCToCpp(); + + // CefTranslatorTestScopedLibraryChild methods. + int GetOtherValue() OVERRIDE; + void SetOtherValue(int value) OVERRIDE; + + // CefTranslatorTestScopedLibrary methods. + int GetValue() OVERRIDE; + void SetValue(int value) OVERRIDE; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.cc b/libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.cc new file mode 100644 index 000000000..c120dd626 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.cc @@ -0,0 +1,118 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h" +#include "libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefOwnPtr CefTranslatorTestScopedLibrary::Create( + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_translator_test_scoped_library_t* _retval = + cef_translator_test_scoped_library_create( + value); + + // Return type: ownptr_same + return CefTranslatorTestScopedLibraryCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefTranslatorTestScopedLibraryCToCpp::GetValue() { + cef_translator_test_scoped_library_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_value(_struct); + + // Return type: simple + return _retval; +} + +void CefTranslatorTestScopedLibraryCToCpp::SetValue(int value) { + cef_translator_test_scoped_library_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_value(_struct, + value); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTranslatorTestScopedLibraryCToCpp::CefTranslatorTestScopedLibraryCToCpp() { +} + +template<> cef_translator_test_scoped_library_t* CefCToCppScoped::UnwrapDerivedOwn( + CefWrapperType type, CefOwnPtr c) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedLibraryChildCToCpp::UnwrapOwn( + CefOwnPtr( + reinterpret_cast(c.release())))); + } + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedLibraryChildChildCToCpp::UnwrapOwn( + CefOwnPtr( + reinterpret_cast(c.release( + ))))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +template<> cef_translator_test_scoped_library_t* CefCToCppScoped::UnwrapDerivedRaw( + CefWrapperType type, CefRawPtr c) { + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedLibraryChildCToCpp::UnwrapRaw( + CefRawPtr( + reinterpret_cast(c)))); + } + if (type == WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD) { + return reinterpret_cast( + CefTranslatorTestScopedLibraryChildChildCToCpp::UnwrapRaw( + CefRawPtr( + reinterpret_cast(c)))); + } + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCppScoped::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCppScoped::kWrapperType = + WT_TRANSLATOR_TEST_SCOPED_LIBRARY; diff --git a/libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h b/libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h new file mode 100644 index 000000000..978316de5 --- /dev/null +++ b/libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h @@ -0,0 +1,39 @@ +// Copyright (c) 2017 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CTOCPP_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/test/cef_translator_test.h" +#include "include/capi/test/cef_translator_test_capi.h" +#include "libcef_dll/ctocpp/ctocpp_scoped.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefTranslatorTestScopedLibraryCToCpp + : public CefCToCppScoped { + public: + CefTranslatorTestScopedLibraryCToCpp(); + + // CefTranslatorTestScopedLibrary methods. + int GetValue() OVERRIDE; + void SetValue(int value) OVERRIDE; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_TEST_TRANSLATOR_TEST_SCOPED_LIBRARY_CTOCPP_H_ diff --git a/libcef_dll/ptr_util.h b/libcef_dll/ptr_util.h new file mode 100644 index 000000000..78e182a01 --- /dev/null +++ b/libcef_dll/ptr_util.h @@ -0,0 +1,19 @@ +// Copyright (c) 2017 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 CEF_LIBCEF_DLL_PTR_UTIL_H_ +#define CEF_LIBCEF_DLL_PTR_UTIL_H_ +#pragma once + +// Helpers for CefOwnPtr<>. +#if defined(USING_CHROMIUM_INCLUDES) +#define OWN_PASS(p) std::move(p) +#define OWN_RETURN_AS(p,t) (p) +#else +#define OWN_PASS(p) (p).Pass() +#define OWN_RETURN_AS(p,t) (p).PassAs() +#endif + +#endif // CEF_LIBCEF_DLL_PTR_UTIL_H_ + diff --git a/libcef_dll/wrapper_types.h b/libcef_dll/wrapper_types.h index 3e49de296..7c0273932 100644 --- a/libcef_dll/wrapper_types.h +++ b/libcef_dll/wrapper_types.h @@ -117,11 +117,16 @@ enum CefWrapperType { WT_TEXTFIELD_DELEGATE, WT_THREAD, WT_TRANSLATOR_TEST, - WT_TRANSLATOR_TEST_HANDLER, - WT_TRANSLATOR_TEST_HANDLER_CHILD, - WT_TRANSLATOR_TEST_OBJECT, - WT_TRANSLATOR_TEST_OBJECT_CHILD, - WT_TRANSLATOR_TEST_OBJECT_CHILD_CHILD, + WT_TRANSLATOR_TEST_REF_PTR_CLIENT, + WT_TRANSLATOR_TEST_REF_PTR_CLIENT_CHILD, + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY, + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD, + WT_TRANSLATOR_TEST_REF_PTR_LIBRARY_CHILD_CHILD, + WT_TRANSLATOR_TEST_SCOPED_CLIENT, + WT_TRANSLATOR_TEST_SCOPED_CLIENT_CHILD, + WT_TRANSLATOR_TEST_SCOPED_LIBRARY, + WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD, + WT_TRANSLATOR_TEST_SCOPED_LIBRARY_CHILD_CHILD, WT_URLREQUEST, WT_URLREQUEST_CLIENT, WT_V8ACCESSOR, diff --git a/tests/cefclient/common/client_app_delegates_common.cc b/tests/cefclient/common/client_app_delegates_common.cc index aa73d25b9..99c3b86c0 100644 --- a/tests/cefclient/common/client_app_delegates_common.cc +++ b/tests/cefclient/common/client_app_delegates_common.cc @@ -9,7 +9,7 @@ namespace client { // static void ClientApp::RegisterCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes) { scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes); } diff --git a/tests/cefclient/common/scheme_test_common.cc b/tests/cefclient/common/scheme_test_common.cc index 042cd2cc8..674799ac6 100644 --- a/tests/cefclient/common/scheme_test_common.cc +++ b/tests/cefclient/common/scheme_test_common.cc @@ -9,7 +9,7 @@ namespace client { namespace scheme_test { -void RegisterCustomSchemes(CefRefPtr registrar, +void RegisterCustomSchemes(CefRawPtr registrar, std::vector& cookiable_schemes) { registrar->AddCustomScheme("client", true, false, false, false, true); } diff --git a/tests/cefclient/common/scheme_test_common.h b/tests/cefclient/common/scheme_test_common.h index 7b3a24da4..859623d91 100644 --- a/tests/cefclient/common/scheme_test_common.h +++ b/tests/cefclient/common/scheme_test_common.h @@ -17,7 +17,7 @@ namespace scheme_test { // See browser/scheme_test.h for creation/registration of the custom scheme // handler which only occurs in the browser process. Called from // client_app_delegates_common.cc. -void RegisterCustomSchemes(CefRefPtr registrar, +void RegisterCustomSchemes(CefRawPtr registrar, std::vector& cookiable_schemes); } // namespace scheme_test diff --git a/tests/ceftests/client_app_delegates.cc b/tests/ceftests/client_app_delegates.cc index b2eaf9b16..c818925ce 100644 --- a/tests/ceftests/client_app_delegates.cc +++ b/tests/ceftests/client_app_delegates.cc @@ -98,23 +98,23 @@ void CreateRenderDelegates(ClientAppRenderer::DelegateSet& delegates) { } void RegisterCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes) { // Bring in the scheme handler tests. extern void RegisterSchemeHandlerCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes); RegisterSchemeHandlerCustomSchemes(registrar, cookiable_schemes); // Bring in the cookie tests. extern void RegisterCookieCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes); RegisterCookieCustomSchemes(registrar, cookiable_schemes); // Bring in the URLRequest tests. extern void RegisterURLRequestCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes); RegisterURLRequestCustomSchemes(registrar, cookiable_schemes); } @@ -139,7 +139,7 @@ void ClientAppRenderer::CreateDelegates(DelegateSet& delegates) { // static void ClientApp::RegisterCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes) { ::RegisterCustomSchemes(registrar, cookiable_schemes); } diff --git a/tests/ceftests/cookie_unittest.cc b/tests/ceftests/cookie_unittest.cc index f12d6efc0..df95ce1f2 100644 --- a/tests/ceftests/cookie_unittest.cc +++ b/tests/ceftests/cookie_unittest.cc @@ -1336,7 +1336,7 @@ TEST(CookieTest, GetCookieManagerCustom) { // Entry point for registering custom schemes. // Called from client_app_delegates.cc. void RegisterCookieCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes) { // Used by GetCookieManagerCustom test. registrar->AddCustomScheme("ccustom", true, false, false, false, true); diff --git a/tests/ceftests/scheme_handler_unittest.cc b/tests/ceftests/scheme_handler_unittest.cc index af26c2995..12eb46f93 100644 --- a/tests/ceftests/scheme_handler_unittest.cc +++ b/tests/ceftests/scheme_handler_unittest.cc @@ -1667,7 +1667,7 @@ TEST(SchemeHandlerTest, AcceptLanguage) { // Entry point for registering custom schemes. // Called from client_app_delegates.cc. void RegisterSchemeHandlerCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes) { // Add a custom standard scheme. registrar->AddCustomScheme("customstd", true, false, false, false, true); diff --git a/tests/ceftests/translator_unittest.cc b/tests/ceftests/translator_unittest.cc index 289c9f6ce..afc4a71ca 100644 --- a/tests/ceftests/translator_unittest.cc +++ b/tests/ceftests/translator_unittest.cc @@ -3,6 +3,7 @@ // can be found in the LICENSE file. #include "include/test/cef_translator_test.h" +#include "tests/ceftests/test_handler.h" #include "tests/gtest/include/gtest/gtest.h" // Test getting/setting primitive types. @@ -168,22 +169,23 @@ TEST(TranslatorTest, StructList) { EXPECT_TRUE(obj->HasOneRef()); } -// Test getting/setting library-side object types. -TEST(TranslatorTest, Object) { +// Test getting/setting library-side RefPtr types. +TEST(TranslatorTest, RefPtrLibrary) { CefRefPtr obj = CefTranslatorTest::Create(); const int kTestVal = 12; - CefRefPtr test_obj = - CefTranslatorTestObject::Create(kTestVal); + CefRefPtr test_obj = + CefTranslatorTestRefPtrLibrary::Create(kTestVal); EXPECT_EQ(kTestVal, test_obj->GetValue()); - int retval = obj->SetObject(test_obj); + int retval = obj->SetRefPtrLibrary(test_obj); EXPECT_EQ(kTestVal, retval); EXPECT_EQ(kTestVal, test_obj->GetValue()); const int kTestVal2 = 30; - CefRefPtr test_obj2 = obj->GetObject(kTestVal2); + CefRefPtr test_obj2 = + obj->GetRefPtrLibrary(kTestVal2); EXPECT_EQ(kTestVal2, test_obj2->GetValue()); - int retval2 = obj->SetObject(test_obj2); + int retval2 = obj->SetRefPtrLibrary(test_obj2); EXPECT_EQ(kTestVal2, retval2); EXPECT_EQ(kTestVal2, test_obj2->GetValue()); @@ -193,39 +195,41 @@ TEST(TranslatorTest, Object) { EXPECT_TRUE(test_obj2->HasOneRef()); } -// Test getting/setting inherited library-side object types. -TEST(TranslatorTest, ObjectInherit) { +// Test getting/setting inherited library-side RefPtr types. +TEST(TranslatorTest, RefPtrLibraryInherit) { CefRefPtr obj = CefTranslatorTest::Create(); const int kTestVal = 12; const int kTestVal2 = 40; - CefRefPtr test_obj = - CefTranslatorTestObjectChild::Create(kTestVal, kTestVal2); + CefRefPtr test_obj = + CefTranslatorTestRefPtrLibraryChild::Create(kTestVal, kTestVal2); EXPECT_EQ(kTestVal, test_obj->GetValue()); EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); - int retval = obj->SetObject(test_obj); + int retval = obj->SetRefPtrLibrary(test_obj); EXPECT_EQ(kTestVal, retval); EXPECT_EQ(kTestVal, test_obj->GetValue()); EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); - EXPECT_EQ(kTestVal, obj->SetChildObject(test_obj)); - EXPECT_EQ(kTestVal, obj->SetChildObjectAndReturnParent(test_obj)->GetValue()); + EXPECT_EQ(kTestVal, obj->SetChildRefPtrLibrary(test_obj)); + EXPECT_EQ(kTestVal, + obj->SetChildRefPtrLibraryAndReturnParent(test_obj)->GetValue()); const int kTestVal3 = 100; - CefRefPtr test_obj2 = - CefTranslatorTestObjectChildChild::Create(kTestVal, kTestVal2, kTestVal3); + CefRefPtr test_obj2 = + CefTranslatorTestRefPtrLibraryChildChild::Create(kTestVal, kTestVal2, + kTestVal3); EXPECT_EQ(kTestVal, test_obj2->GetValue()); EXPECT_EQ(kTestVal2, test_obj2->GetOtherValue()); EXPECT_EQ(kTestVal3, test_obj2->GetOtherOtherValue()); - int retval2 = obj->SetObject(test_obj2); + int retval2 = obj->SetRefPtrLibrary(test_obj2); EXPECT_EQ(kTestVal, retval2); EXPECT_EQ(kTestVal, test_obj2->GetValue()); EXPECT_EQ(kTestVal2, test_obj2->GetOtherValue()); EXPECT_EQ(kTestVal3, test_obj2->GetOtherOtherValue()); - EXPECT_EQ(kTestVal, obj->SetChildObject(test_obj2)); + EXPECT_EQ(kTestVal, obj->SetChildRefPtrLibrary(test_obj2)); EXPECT_EQ(kTestVal, - obj->SetChildObjectAndReturnParent(test_obj2)->GetValue()); + obj->SetChildRefPtrLibraryAndReturnParent(test_obj2)->GetValue()); // Only one reference to the object should exist. EXPECT_TRUE(obj->HasOneRef()); @@ -233,25 +237,25 @@ TEST(TranslatorTest, ObjectInherit) { EXPECT_TRUE(test_obj2->HasOneRef()); } -// Test getting/setting library-side object list types. -TEST(TranslatorTest, ObjectList) { +// Test getting/setting library-side RefPtr list types. +TEST(TranslatorTest, RefPtrLibraryList) { CefRefPtr obj = CefTranslatorTest::Create(); const int kVal1 = 34; const int kVal2 = 10; - CefRefPtr val1 = - CefTranslatorTestObject::Create(kVal1); - CefRefPtr val2 = - CefTranslatorTestObjectChild::Create(kVal2, 0); + CefRefPtr val1 = + CefTranslatorTestRefPtrLibrary::Create(kVal1); + CefRefPtr val2 = + CefTranslatorTestRefPtrLibraryChild::Create(kVal2, 0); - std::vector > list; + std::vector > list; list.push_back(val1); list.push_back(val2); - EXPECT_TRUE(obj->SetObjectList(list, kVal1, kVal2)); + EXPECT_TRUE(obj->SetRefPtrLibraryList(list, kVal1, kVal2)); list.clear(); - EXPECT_TRUE(obj->GetObjectListByRef(list, kVal1, kVal2)); + EXPECT_TRUE(obj->GetRefPtrLibraryListByRef(list, kVal1, kVal2)); EXPECT_EQ(2U, list.size()); EXPECT_EQ(kVal1, list[0]->GetValue()); EXPECT_EQ(kVal2, list[1]->GetValue()); @@ -266,9 +270,9 @@ TEST(TranslatorTest, ObjectList) { namespace { -class TranslatorTestHandler : public CefTranslatorTestHandler { +class TranslatorTestRefPtrClient : public CefTranslatorTestRefPtrClient { public: - explicit TranslatorTestHandler(const int val) + explicit TranslatorTestRefPtrClient(const int val) : val_(val) { } @@ -279,13 +283,14 @@ class TranslatorTestHandler : public CefTranslatorTestHandler { private: const int val_; - IMPLEMENT_REFCOUNTING(TranslatorTestHandler); - DISALLOW_COPY_AND_ASSIGN(TranslatorTestHandler); + IMPLEMENT_REFCOUNTING(TranslatorTestRefPtrClient); + DISALLOW_COPY_AND_ASSIGN(TranslatorTestRefPtrClient); }; -class TranslatorTestHandlerChild : public CefTranslatorTestHandlerChild { +class TranslatorTestRefPtrClientChild : + public CefTranslatorTestRefPtrClientChild { public: - TranslatorTestHandlerChild(const int val, + TranslatorTestRefPtrClientChild(const int val, const int other_val) : val_(val), other_val_(other_val) { @@ -303,24 +308,24 @@ class TranslatorTestHandlerChild : public CefTranslatorTestHandlerChild { const int val_; const int other_val_; - IMPLEMENT_REFCOUNTING(TranslatorTestHandlerChild); - DISALLOW_COPY_AND_ASSIGN(TranslatorTestHandlerChild); + IMPLEMENT_REFCOUNTING(TranslatorTestRefPtrClientChild); + DISALLOW_COPY_AND_ASSIGN(TranslatorTestRefPtrClientChild); }; } // namespace -// Test getting/setting client-side handler types. -TEST(TranslatorTest, Handler) { +// Test getting/setting client-side RefPtr types. +TEST(TranslatorTest, RefPtrClient) { CefRefPtr obj = CefTranslatorTest::Create(); const int kTestVal = 12; - CefRefPtr test_obj = - new TranslatorTestHandler(kTestVal); + CefRefPtr test_obj = + new TranslatorTestRefPtrClient(kTestVal); EXPECT_EQ(kTestVal, test_obj->GetValue()); - EXPECT_EQ(kTestVal, obj->SetHandler(test_obj.get())); - CefRefPtr handler = - obj->SetHandlerAndReturn(test_obj.get()); + EXPECT_EQ(kTestVal, obj->SetRefPtrClient(test_obj.get())); + CefRefPtr handler = + obj->SetRefPtrClientAndReturn(test_obj.get()); EXPECT_EQ(test_obj.get(), handler.get()); EXPECT_EQ(kTestVal, handler->GetValue()); handler = NULL; @@ -330,25 +335,25 @@ TEST(TranslatorTest, Handler) { EXPECT_TRUE(test_obj->HasOneRef()); } -// Test getting/setting inherited client-side handler types. -TEST(TranslatorTest, HandlerInherit) { +// Test getting/setting inherited client-side RefPtr types. +TEST(TranslatorTest, RefPtrClientInherit) { CefRefPtr obj = CefTranslatorTest::Create(); const int kTestVal = 12; const int kTestVal2 = 86; - CefRefPtr test_obj = - new TranslatorTestHandlerChild(kTestVal, kTestVal2); + CefRefPtr test_obj = + new TranslatorTestRefPtrClientChild(kTestVal, kTestVal2); EXPECT_EQ(kTestVal, test_obj->GetValue()); EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); - int retval = obj->SetHandler(test_obj); + int retval = obj->SetRefPtrClient(test_obj); EXPECT_EQ(kTestVal, retval); EXPECT_EQ(kTestVal, test_obj->GetValue()); EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); - EXPECT_EQ(kTestVal, obj->SetChildHandler(test_obj)); - CefRefPtr handler = - obj->SetChildHandlerAndReturnParent(test_obj); + EXPECT_EQ(kTestVal, obj->SetChildRefPtrClient(test_obj)); + CefRefPtr handler = + obj->SetChildRefPtrClientAndReturnParent(test_obj); EXPECT_EQ(kTestVal, handler->GetValue()); EXPECT_EQ(test_obj.get(), handler.get()); handler = NULL; @@ -358,24 +363,25 @@ TEST(TranslatorTest, HandlerInherit) { EXPECT_TRUE(test_obj->HasOneRef()); } -// Test getting/setting client-side object list types. -TEST(TranslatorTest, HandlerList) { +// Test getting/setting client-side RefPtr list types. +TEST(TranslatorTest, RefPtrClientList) { CefRefPtr obj = CefTranslatorTest::Create(); const int kVal1 = 34; const int kVal2 = 10; - CefRefPtr val1 = new TranslatorTestHandler(kVal1); - CefRefPtr val2 = - new TranslatorTestHandlerChild(kVal2, 0); + CefRefPtr val1 = + new TranslatorTestRefPtrClient(kVal1); + CefRefPtr val2 = + new TranslatorTestRefPtrClientChild(kVal2, 0); - std::vector > list; + std::vector > list; list.push_back(val1); list.push_back(val2); - EXPECT_TRUE(obj->SetHandlerList(list, kVal1, kVal2)); + EXPECT_TRUE(obj->SetRefPtrClientList(list, kVal1, kVal2)); list.clear(); - EXPECT_TRUE(obj->GetHandlerListByRef(list, val1, val2)); + EXPECT_TRUE(obj->GetRefPtrClientListByRef(list, val1, val2)); EXPECT_EQ(2U, list.size()); EXPECT_EQ(kVal1, list[0]->GetValue()); EXPECT_EQ(val1.get(), list[0].get()); @@ -389,3 +395,374 @@ TEST(TranslatorTest, HandlerList) { EXPECT_TRUE(val1->HasOneRef()); EXPECT_TRUE(val2->HasOneRef()); } + + +// Test getting/setting library-side OwnPtr types. +TEST(TranslatorTest, OwnPtrLibrary) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + CefOwnPtr test_obj = + CefTranslatorTestScopedLibrary::Create(kTestVal); + EXPECT_TRUE(test_obj.get()); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + int retval = obj->SetOwnPtrLibrary(test_obj.Pass()); + EXPECT_EQ(kTestVal, retval); + EXPECT_FALSE(test_obj.get()); + + const int kTestVal2 = 30; + CefOwnPtr test_obj2 = + obj->GetOwnPtrLibrary(kTestVal2); + EXPECT_TRUE(test_obj2.get()); + EXPECT_EQ(kTestVal2, test_obj2->GetValue()); + int retval2 = obj->SetOwnPtrLibrary(test_obj2.Pass()); + EXPECT_EQ(kTestVal2, retval2); + EXPECT_FALSE(test_obj2.get()); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting inherited library-side OwnPtr types. +TEST(TranslatorTest, OwnPtrLibraryInherit) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + const int kTestVal2 = 40; + CefOwnPtr test_obj = + CefTranslatorTestScopedLibraryChild::Create(kTestVal, kTestVal2); + EXPECT_TRUE(test_obj.get()); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); + int retval = obj->SetOwnPtrLibrary( + test_obj.PassAs()); + EXPECT_EQ(kTestVal, retval); + EXPECT_FALSE(test_obj.get()); + + test_obj = CefTranslatorTestScopedLibraryChild::Create(kTestVal, kTestVal2); + EXPECT_TRUE(test_obj.get()); + EXPECT_EQ(kTestVal, obj->SetChildOwnPtrLibrary(test_obj.Pass())); + EXPECT_FALSE(test_obj.get()); + + test_obj = CefTranslatorTestScopedLibraryChild::Create(kTestVal, kTestVal2); + EXPECT_TRUE(test_obj.get()); + CefOwnPtr test_obj_parent = + obj->SetChildOwnPtrLibraryAndReturnParent(test_obj.Pass()); + EXPECT_FALSE(test_obj.get()); + EXPECT_TRUE(test_obj_parent.get()); + EXPECT_EQ(kTestVal, test_obj_parent->GetValue()); + test_obj_parent.reset(NULL); + + const int kTestVal3 = 100; + CefOwnPtr test_obj2 = + CefTranslatorTestScopedLibraryChildChild::Create(kTestVal, kTestVal2, + kTestVal3); + EXPECT_EQ(kTestVal, test_obj2->GetValue()); + EXPECT_EQ(kTestVal2, test_obj2->GetOtherValue()); + EXPECT_EQ(kTestVal3, test_obj2->GetOtherOtherValue()); + int retval2 = obj->SetOwnPtrLibrary( + test_obj2.PassAs()); + EXPECT_EQ(kTestVal, retval2); + EXPECT_FALSE(test_obj2.get()); + + test_obj2 = CefTranslatorTestScopedLibraryChildChild::Create( + kTestVal, kTestVal2, kTestVal3); + EXPECT_EQ(kTestVal, obj->SetChildOwnPtrLibrary( + test_obj2.PassAs())); + EXPECT_FALSE(test_obj2.get()); + + test_obj2 = CefTranslatorTestScopedLibraryChildChild::Create( + kTestVal, kTestVal2, kTestVal3); + test_obj_parent = obj->SetChildOwnPtrLibraryAndReturnParent( + test_obj2.PassAs()); + EXPECT_FALSE(test_obj2.get()); + EXPECT_TRUE(test_obj_parent.get()); + EXPECT_EQ(kTestVal, test_obj_parent->GetValue()); + test_obj_parent.reset(NULL); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +namespace { + +class TranslatorTestScopedClient : public CefTranslatorTestScopedClient { + public: + TranslatorTestScopedClient(const int val, + TrackCallback* got_delete) + : val_(val), + got_delete_(got_delete) { + } + ~TranslatorTestScopedClient() override { + got_delete_->yes(); + } + + virtual int GetValue() override { + return val_; + } + + private: + const int val_; + TrackCallback* got_delete_; + + DISALLOW_COPY_AND_ASSIGN(TranslatorTestScopedClient); +}; + +class TranslatorTestScopedClientChild : + public CefTranslatorTestScopedClientChild { + public: + TranslatorTestScopedClientChild(const int val, + const int other_val, + TrackCallback* got_delete) + : val_(val), + other_val_(other_val), + got_delete_(got_delete) { + } + ~TranslatorTestScopedClientChild() override { + got_delete_->yes(); + } + + virtual int GetValue() override { + return val_; + } + + virtual int GetOtherValue() override { + return other_val_; + } + + private: + const int val_; + const int other_val_; + TrackCallback* got_delete_; + + DISALLOW_COPY_AND_ASSIGN(TranslatorTestScopedClientChild); +}; + +} // namespace + +// Test getting/setting client-side OwnPtr types. +TEST(TranslatorTest, OwnPtrClient) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + TrackCallback got_delete; + + CefOwnPtr test_obj( + new TranslatorTestScopedClient(kTestVal, &got_delete)); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal, obj->SetOwnPtrClient(test_obj.Pass())); + EXPECT_FALSE(test_obj.get()); + EXPECT_TRUE(got_delete); + + got_delete.reset(); + test_obj.reset(new TranslatorTestScopedClient(kTestVal, &got_delete)); + CefOwnPtr handler = + obj->SetOwnPtrClientAndReturn(test_obj.Pass()); + EXPECT_FALSE(test_obj.get()); + EXPECT_TRUE(handler.get()); + EXPECT_FALSE(got_delete); + EXPECT_EQ(kTestVal, handler->GetValue()); + handler.reset(NULL); + EXPECT_TRUE(got_delete); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting inherited client-side OwnPtr types. +TEST(TranslatorTest, OwnPtrClientInherit) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + const int kTestVal2 = 86; + TrackCallback got_delete; + + CefOwnPtr test_obj( + new TranslatorTestScopedClientChild(kTestVal, kTestVal2, &got_delete)); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); + EXPECT_EQ(kTestVal, obj->SetOwnPtrClient( + test_obj.PassAs())); + EXPECT_FALSE(test_obj.get()); + EXPECT_TRUE(got_delete); + + got_delete.reset(); + test_obj.reset( + new TranslatorTestScopedClientChild(kTestVal, kTestVal2, &got_delete)); + EXPECT_EQ(kTestVal, obj->SetChildOwnPtrClient(test_obj.Pass())); + EXPECT_FALSE(test_obj.get()); + EXPECT_TRUE(got_delete); + + got_delete.reset(); + test_obj.reset( + new TranslatorTestScopedClientChild(kTestVal, kTestVal2, &got_delete)); + CefOwnPtr handler( + obj->SetChildOwnPtrClientAndReturnParent(test_obj.Pass())); + EXPECT_EQ(kTestVal, handler->GetValue()); + EXPECT_FALSE(test_obj.get()); + EXPECT_FALSE(got_delete); + handler.reset(NULL); + EXPECT_TRUE(got_delete); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting library-side RawPtr types. +TEST(TranslatorTest, RawPtrLibrary) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + CefOwnPtr test_obj( + CefTranslatorTestScopedLibrary::Create(kTestVal)); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + int retval = obj->SetRawPtrLibrary(test_obj.get()); + EXPECT_EQ(kTestVal, retval); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + + const int kTestVal2 = 30; + CefOwnPtr test_obj2( + obj->GetOwnPtrLibrary(kTestVal2)); + EXPECT_EQ(kTestVal2, test_obj2->GetValue()); + int retval2 = obj->SetRawPtrLibrary(test_obj2.get()); + EXPECT_EQ(kTestVal2, retval2); + EXPECT_EQ(kTestVal2, test_obj2->GetValue()); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting inherited library-side RawPtr types. +TEST(TranslatorTest, RawPtrLibraryInherit) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + const int kTestVal2 = 40; + CefOwnPtr test_obj( + CefTranslatorTestScopedLibraryChild::Create(kTestVal, kTestVal2)); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); + int retval = obj->SetRawPtrLibrary(test_obj.get()); + EXPECT_EQ(kTestVal, retval); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); + + EXPECT_EQ(kTestVal, obj->SetChildRawPtrLibrary(test_obj.get())); + + const int kTestVal3 = 100; + CefOwnPtr test_obj2( + CefTranslatorTestScopedLibraryChildChild::Create(kTestVal, kTestVal2, + kTestVal3)); + EXPECT_EQ(kTestVal, test_obj2->GetValue()); + EXPECT_EQ(kTestVal2, test_obj2->GetOtherValue()); + EXPECT_EQ(kTestVal3, test_obj2->GetOtherOtherValue()); + int retval2 = obj->SetRawPtrLibrary(test_obj2.get()); + EXPECT_EQ(kTestVal, retval2); + EXPECT_EQ(kTestVal, test_obj2->GetValue()); + EXPECT_EQ(kTestVal2, test_obj2->GetOtherValue()); + EXPECT_EQ(kTestVal3, test_obj2->GetOtherOtherValue()); + + EXPECT_EQ(kTestVal, obj->SetChildRawPtrLibrary(test_obj2.get())); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting library-side RawPtr list types. +TEST(TranslatorTest, RawPtrLibraryList) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kVal1 = 34; + const int kVal2 = 10; + + CefOwnPtr val1( + CefTranslatorTestScopedLibrary::Create(kVal1)); + CefOwnPtr val2( + CefTranslatorTestScopedLibraryChild::Create(kVal2, 0)); + + std::vector > list; + list.push_back(val1.get()); + list.push_back(val2.get()); + EXPECT_TRUE(obj->SetRawPtrLibraryList(list, kVal1, kVal2)); + list.clear(); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting client-side RawPtr types. +TEST(TranslatorTest, RawPtrClient) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + TrackCallback got_delete; + + CefOwnPtr test_obj( + new TranslatorTestScopedClient(kTestVal, &got_delete)); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal, obj->SetRawPtrClient(test_obj.get())); + EXPECT_FALSE(got_delete); + test_obj.reset(NULL); + EXPECT_TRUE(got_delete); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting inherited client-side RawPtr types. +TEST(TranslatorTest, RawPtrClientInherit) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kTestVal = 12; + const int kTestVal2 = 86; + TrackCallback got_delete; + + CefOwnPtr test_obj( + new TranslatorTestScopedClientChild(kTestVal, kTestVal2, &got_delete)); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); + int retval = obj->SetRawPtrClient(test_obj.get()); + EXPECT_EQ(kTestVal, retval); + EXPECT_EQ(kTestVal, test_obj->GetValue()); + EXPECT_EQ(kTestVal2, test_obj->GetOtherValue()); + EXPECT_FALSE(got_delete); + + EXPECT_EQ(kTestVal, obj->SetChildRawPtrClient(test_obj.get())); + EXPECT_FALSE(got_delete); + test_obj.reset(NULL); + EXPECT_TRUE(got_delete); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} + +// Test getting/setting client-side RawPtr list types. +TEST(TranslatorTest, RawPtrClientList) { + CefRefPtr obj = CefTranslatorTest::Create(); + + const int kVal1 = 34; + const int kVal2 = 10; + TrackCallback got_delete1, got_delete2; + + CefOwnPtr val1( + new TranslatorTestScopedClient(kVal1, &got_delete1)); + CefOwnPtr val2( + new TranslatorTestScopedClientChild(kVal2, 0, &got_delete2)); + + std::vector > list; + list.push_back(val1.get()); + list.push_back(val2.get()); + EXPECT_TRUE(obj->SetRawPtrClientList(list, kVal1, kVal2)); + list.clear(); + + EXPECT_FALSE(got_delete1); + val1.reset(NULL); + EXPECT_TRUE(got_delete1); + + EXPECT_FALSE(got_delete2); + val2.reset(NULL); + EXPECT_TRUE(got_delete2); + + // Only one reference to the object should exist. + EXPECT_TRUE(obj->HasOneRef()); +} diff --git a/tests/ceftests/urlrequest_unittest.cc b/tests/ceftests/urlrequest_unittest.cc index 7c55116a1..52e007b2b 100644 --- a/tests/ceftests/urlrequest_unittest.cc +++ b/tests/ceftests/urlrequest_unittest.cc @@ -1422,7 +1422,7 @@ void CreateURLRequestRendererTests(ClientAppRenderer::DelegateSet& delegates) { // Entry point for registering custom schemes. // Called from client_app_delegates.cc. void RegisterURLRequestCustomSchemes( - CefRefPtr registrar, + CefRawPtr registrar, std::vector& cookiable_schemes) { registrar->AddCustomScheme(kRequestScheme, true, false, false, false, true); cookiable_schemes.push_back(kRequestScheme); diff --git a/tests/shared/common/client_app.cc b/tests/shared/common/client_app.cc index 4083c1422..4ca5df9ad 100644 --- a/tests/shared/common/client_app.cc +++ b/tests/shared/common/client_app.cc @@ -42,7 +42,7 @@ ClientApp::ProcessType ClientApp::GetProcessType( } void ClientApp::OnRegisterCustomSchemes( - CefRefPtr registrar) { + CefRawPtr registrar) { RegisterCustomSchemes(registrar, cookieable_schemes_); } diff --git a/tests/shared/common/client_app.h b/tests/shared/common/client_app.h index d36611089..225f80805 100644 --- a/tests/shared/common/client_app.h +++ b/tests/shared/common/client_app.h @@ -34,12 +34,12 @@ class ClientApp : public CefApp { private: // Registers custom schemes. Implemented by cefclient in // client_app_delegates_common.cc - static void RegisterCustomSchemes(CefRefPtr registrar, + static void RegisterCustomSchemes(CefRawPtr registrar, std::vector& cookiable_schemes); // CefApp methods. void OnRegisterCustomSchemes( - CefRefPtr registrar) OVERRIDE; + CefRawPtr registrar) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(ClientApp); }; diff --git a/tools/cef_parser.py b/tools/cef_parser.py index f8f0111f5..0fbfc1f81 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -94,6 +94,12 @@ def wrap_code(code, indent = ' ', maxchars = 80, splitchars = '(=,'): return output +def is_base_class(clsname): + """ Returns true if |clsname| is a known base (root) class in the object + hierarchy. + """ + return clsname == 'CefBase' or clsname == 'CefBaseScoped' + def get_capi_file_name(cppname): """ Convert a C++ header file name to a C API header file name. """ return cppname[:-2]+'_capi.h' @@ -302,7 +308,7 @@ def format_translation_includes(header, body): list = sorted(set(p.findall(body))) for item in list: directory = '' - if item != 'CefBase': + if not is_base_class(item): cls = header.get_class(item) dir = cls.get_file_directory() if not dir is None: @@ -315,7 +321,7 @@ def format_translation_includes(header, body): list = sorted(set(p.findall(body))) for item in list: directory = '' - if item != 'CefBase': + if not is_base_class(item): cls = header.get_class(item) dir = cls.get_file_directory() if not dir is None: @@ -383,9 +389,9 @@ _cre_cfnameorpath = '([A-Za-z0-9_\/]{1,})' # regex for matching function return values _cre_retval = '([A-Za-z0-9_<>:,\*\&]{1,})' # regex for matching typedef value and name combination -_cre_typedef = '([A-Za-z0-9_<>:,\*\& ]{1,})' +_cre_typedef = '([A-Za-z0-9_<>:,\*\&\s]{1,})' # regex for matching function return value and name combination -_cre_func = '([A-Za-z][A-Za-z0-9_<>:,\*\& ]{1,})' +_cre_func = '([A-Za-z][A-Za-z0-9_<>:,\*\&\s]{1,})' # regex for matching virtual function modifiers _cre_vfmod = '([A-Za-z0-9_]{0,})' # regex for matching arbitrary whitespace @@ -554,8 +560,8 @@ class obj_header: pos = value.rfind(' ') if pos < 0: raise Exception('Invalid typedef: '+value) - alias = value[pos+1:] - value = value[:pos] + alias = value[pos+1:].strip() + value = value[:pos].strip() self.typedefs.append(obj_typedef(self, filename, value, alias)) # extract global functions @@ -592,7 +598,7 @@ class obj_header: # build the class objects for attrib, name, parent_name, body in list: - comment = get_comment(data, name+' : public') + comment = get_comment(data, name+' :') validate_comment(filename, name, comment) self.classes.append( obj_class(self, filename, attrib, name, parent_name, body, @@ -673,6 +679,20 @@ class obj_header: result.append(cls.get_name()) return result + def get_base_class_name(self, classname): + """ Returns the base (root) class name for |classname|. """ + cur_cls = self.get_class(classname) + while True: + parent_name = cur_cls.get_parent_name() + if is_base_class(parent_name): + return parent_name + else: + parent_cls = self.get_class(parent_name) + if parent_cls is None: + break + cur_cls = self.get_class(parent_name) + return None + def get_types(self, list): """ Return a dictionary mapping data types to analyzed values. """ for cls in self.typedefs: @@ -695,7 +715,7 @@ class obj_header: def get_defined_structs(self): """ Return a list of already defined structure names. """ - return ['cef_print_info_t', 'cef_window_info_t', 'cef_base_t'] + return ['cef_print_info_t', 'cef_window_info_t', 'cef_base_t', 'cef_base_scoped_t'] def get_capi_translations(self): """ Return a dictionary that maps C++ terminology to C API terminology. @@ -760,8 +780,8 @@ class obj_class: pos = value.rfind(' ') if pos < 0: raise Exception('Invalid typedef: '+value) - alias = value[pos+1:] - value = value[:pos] + alias = value[pos+1:].strip() + value = value[:pos].strip() self.typedefs.append(obj_typedef(self, filename, value, alias)) # extract static functions @@ -856,16 +876,16 @@ class obj_class: def has_parent(self, parent_name): """ Returns true if this class has the specified class anywhere in its inheritance hierarchy. """ - # Every class has CefBase as the top-most parent. - if parent_name == 'CefBase' or parent_name == self.parent_name: + # Every class has a known base class as the top-most parent. + if is_base_class(parent_name) or parent_name == self.parent_name: return True - if self.parent_name == 'CefBase': + if is_base_class(self.parent_name): return False cur_cls = self.parent.get_class(self.parent_name) while True: cur_parent_name = cur_cls.get_parent_name() - if cur_parent_name == 'CefBase': + if is_base_class(cur_parent_name): break elif cur_parent_name == parent_name: return True @@ -1214,7 +1234,7 @@ class obj_function: this_is_library_side = True header = self.parent - if other_class_name == 'CefBase': + if is_base_class(other_class_name): other_is_library_side = False else: other_class = header.get_class(other_class_name) @@ -1386,17 +1406,17 @@ class obj_argument: return 'string_byref_const' return 'string_byref' - # refptr type - if self.type.is_result_refptr(): - same_side = self.parent.is_same_side(self.type.get_refptr_type()) + # *ptr type + if self.type.is_result_ptr(): + prefix = self.type.get_result_ptr_type_prefix() + same_side = self.parent.is_same_side(self.type.get_ptr_type()) if self.type.is_byref(): if same_side: - return 'refptr_same_byref' - return 'refptr_diff_byref' + return prefix + 'ptr_same_byref' + return prefix + 'ptr_diff_byref' if same_side: - return 'refptr_same' - return 'refptr_diff' - + return prefix + 'ptr_same' + return prefix + 'ptr_diff' if self.type.is_result_vector(): # all vector types must be passed by reference @@ -1421,17 +1441,17 @@ class obj_argument: return 'bool_vec_byref_const' return 'bool_vec_byref' - if self.type.is_result_vector_refptr(): - # refptr vector types - same_side = self.parent.is_same_side(self.type.get_refptr_type()) + if self.type.is_result_vector_ptr(): + # *ptr vector types + prefix = self.type.get_result_vector_ptr_type_prefix() + same_side = self.parent.is_same_side(self.type.get_ptr_type()) if self.type.is_const(): if same_side: - return 'refptr_vec_same_byref_const' - return 'refptr_vec_diff_byref_const' + return prefix + 'ptr_vec_same_byref_const' + return prefix + 'ptr_vec_diff_byref_const' if same_side: - return 'refptr_vec_same_byref' - return 'refptr_vec_diff_byref' - + return prefix + 'ptr_vec_same_byref' + return prefix + 'ptr_vec_diff_byref' # string single map type if self.type.is_result_map_single(): @@ -1476,11 +1496,12 @@ class obj_argument: if self.type.is_result_string(): return 'string' - if self.type.is_result_refptr(): - if self.parent.is_same_side(self.type.get_refptr_type()): - return 'refptr_same' + if self.type.is_result_ptr(): + prefix = self.type.get_result_ptr_type_prefix() + if self.parent.is_same_side(self.type.get_ptr_type()): + return prefix + 'ptr_same' else: - return 'refptr_diff' + return prefix + 'ptr_diff' return 'invalid' @@ -1509,8 +1530,14 @@ class obj_argument: if for_capi: return 'NULL' return 'CefString()' - elif type == 'refptr_same' or type == 'refptr_diff': + elif type == 'refptr_same' or type == 'refptr_diff' or \ + type == 'rawptr_same' or type == 'rawptr_diff': return 'NULL' + elif type == 'ownptr_same' or type == 'ownptr_diff': + if for_capi: + return 'NULL' + else: + return 'CefOwnPtr<'+self.type.get_ptr_type()+'>()' return '' @@ -1522,7 +1549,7 @@ class obj_analysis: self.result_type = 'unknown' self.result_value = None self.result_default = None - self.refptr_type = None + self.ptr_type = None # parse the argument string partlist = string.split(string.strip(value)) @@ -1626,8 +1653,8 @@ class obj_analysis: if not basic is None: self.result_type = basic['result_type'] self.result_value = basic['result_value'] - if 'refptr_type' in basic: - self.refptr_type = basic['refptr_type'] + if 'ptr_type' in basic: + self.ptr_type = basic['ptr_type'] if 'result_default' in basic: self.result_default = basic['result_default'] return True @@ -1664,7 +1691,27 @@ class obj_analysis: return { 'result_type' : 'refptr', 'result_value' : get_capi_name(list[0], True)+'*', - 'refptr_type' : list[0] + 'ptr_type' : list[0] + } + + # check for CEF owned pointers + p = re.compile('^CefOwnPtr<(.*?)>$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'ownptr', + 'result_value' : get_capi_name(list[0], True)+'*', + 'ptr_type' : list[0] + } + + # check for CEF raw pointers + p = re.compile('^CefRawPtr<(.*?)>$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'rawptr', + 'result_value' : get_capi_name(list[0], True)+'*', + 'ptr_type' : list[0] } # check for CEF structure types @@ -1695,13 +1742,13 @@ class obj_analysis: """ Return the C++ type. """ return self.type - def get_refptr_type(self): + def get_ptr_type(self): """ Return the C++ class type referenced by a CefRefPtr. """ - if self.is_result_vector() and self.is_result_vector_refptr(): + if self.is_result_vector() and self.is_result_vector_ptr(): # return the vector RefPtr type - return self.result_value[0]['refptr_type'] + return self.result_value[0]['ptr_type'] # return the basic RefPtr type - return self.refptr_type + return self.ptr_type def get_vector_type(self): """ Return the C++ class type referenced by a std::vector. """ @@ -1743,16 +1790,17 @@ class obj_analysis: """ Return the default value fo the basic type. """ return self.result_default - def is_result_refptr(self): - """ Returns true if this is a reference pointer type. """ - return (self.result_type == 'refptr') + def is_result_ptr(self): + """ Returns true if this is a *Ptr type. """ + return self.is_result_refptr() or self.is_result_ownptr() or \ + self.is_result_rawptr() - def get_result_refptr_type_root(self): - """ Return the refptr type structure name. """ + def get_result_ptr_type_root(self): + """ Return the *Ptr type structure name. """ return self.result_value[:-1] - def get_result_refptr_type(self, defined_structs = []): - """ Return the refptr type. """ + def get_result_ptr_type(self, defined_structs = []): + """ Return the *Ptr type. """ result = '' if not self.result_value[:-1] in defined_structs: result += 'struct _' @@ -1761,6 +1809,28 @@ class obj_analysis: result += '*' return result + def get_result_ptr_type_prefix(self): + """ Returns the *Ptr type prefix. """ + if self.is_result_refptr(): + return 'ref' + if self.is_result_ownptr(): + return 'own' + if self.is_result_rawptr(): + return 'raw' + raise Exception('Not a pointer type') + + def is_result_refptr(self): + """ Returns true if this is a RefPtr type. """ + return (self.result_type == 'refptr') + + def is_result_ownptr(self): + """ Returns true if this is a OwnPtr type. """ + return (self.result_type == 'ownptr') + + def is_result_rawptr(self): + """ Returns true if this is a RawPtr type. """ + return (self.result_type == 'rawptr') + def is_result_struct(self): """ Returns true if this is a structure type. """ return (self.result_type == 'structure') @@ -1816,10 +1886,34 @@ class obj_analysis: """ Returns true if this is a string vector. """ return self.result_value[0]['result_type'] == 'simple' + def is_result_vector_ptr(self): + """ Returns true if this is a *Ptr vector. """ + return self.is_result_vector_refptr() or \ + self.is_result_vector_ownptr() or \ + self.is_result_vector_rawptr() + + def get_result_vector_ptr_type_prefix(self): + """ Returns the *Ptr type prefix. """ + if self.is_result_vector_refptr(): + return 'ref' + if self.is_result_vector_ownptr(): + return 'own' + if self.is_result_vector_rawptr(): + return 'raw' + raise Exception('Not a pointer type') + def is_result_vector_refptr(self): - """ Returns true if this is a string vector. """ + """ Returns true if this is a RefPtr vector. """ return self.result_value[0]['result_type'] == 'refptr' + def is_result_vector_ownptr(self): + """ Returns true if this is a OwnPtr vector. """ + return self.result_value[0]['result_type'] == 'ownptr' + + def is_result_vector_rawptr(self): + """ Returns true if this is a RawPtr vector. """ + return self.result_value[0]['result_type'] == 'rawptr' + def get_result_vector_type_root(self): """ Return the vector structure or basic type name. """ return self.result_value[0]['result_value'] @@ -1844,7 +1938,7 @@ class obj_analysis: str += ' const' str += '*' result['value'] = str - elif type == 'refptr': + elif type == 'refptr' or type == 'ownptr' or type == 'rawptr': str = '' if not value[:-1] in defined_structs: str += 'struct _' @@ -1897,8 +1991,8 @@ class obj_analysis: 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_ptr(): + result += self.get_result_ptr_type(defined_structs) elif self.is_result_struct(): result += self.get_result_struct_type(defined_structs) elif self.is_result_string(): diff --git a/tools/make_cpptoc_header.py b/tools/make_cpptoc_header.py index 1e68b8011..1ca8a6d7d 100644 --- a/tools/make_cpptoc_header.py +++ b/tools/make_cpptoc_header.py @@ -51,10 +51,17 @@ def make_cpptoc_header(header, clsname): result += '#include "include/'+dcls.get_file_name()+'"\n' \ '#include "include/capi/'+dcls.get_capi_file_name()+'"\n' - result += """#include "libcef_dll/cpptoc/cpptoc.h" + base_class_name = header.get_base_class_name(clsname) + base_scoped = True if base_class_name == 'CefBaseScoped' else False + if base_scoped: + template_file = 'cpptoc_scoped.h' + template_class = 'CefCppToCScoped' + else: + template_file = 'cpptoc.h' + template_class = 'CefCppToC' -// Wrap a C++ class with a C structure. -""" + result += '#include "libcef_dll/cpptoc/' + template_file + '"' + result += '\n\n// Wrap a C++ class with a C structure.\n' if dllside: result += '// This class may be instantiated and accessed DLL-side only.\n' @@ -62,7 +69,7 @@ def make_cpptoc_header(header, clsname): result += '// This class may be instantiated and accessed wrapper-side only.\n' result += 'class '+clsname+'CppToC\n'+ \ - ' : public CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'> {\n'+ \ + ' : public ' + template_class + '<'+clsname+'CppToC, '+clsname+', '+capiname+'> {\n'+ \ ' public:\n'+ \ ' '+clsname+'CppToC();\n'+ \ '};\n\n' diff --git a/tools/make_cpptoc_impl.py b/tools/make_cpptoc_impl.py index 9c2142b82..3c42c4d95 100644 --- a/tools/make_cpptoc_impl.py +++ b/tools/make_cpptoc_impl.py @@ -94,6 +94,10 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): arg_type == 'string_byref_const' or arg_type == 'string_byref' or \ arg_type == 'refptr_same' or arg_type == 'refptr_same_byref' or \ arg_type == 'refptr_diff' or arg_type == 'refptr_diff_byref' or \ + arg_type == 'ownptr_same' or arg_type == 'ownptr_same_byref' or \ + arg_type == 'ownptr_diff' or arg_type == 'ownptr_diff_byref' or \ + arg_type == 'rawptr_same' or arg_type == 'rawptr_same_byref' or \ + arg_type == 'rawptr_diff' or arg_type == 'rawptr_diff_byref' or \ arg_type == 'string_vec_byref' or arg_type == 'string_vec_byref_const' or \ arg_type == 'string_map_single_byref' or arg_type == 'string_map_single_byref_const' or \ arg_type == 'string_map_multi_byref' or arg_type == 'string_map_multi_byref_const': @@ -102,13 +106,17 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): '\n if (!'+arg_name+')'\ '\n return'+retval_default+';' elif arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref' or \ - arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref': + arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref' or \ + arg_type == 'ownptr_vec_same_byref' or arg_type == 'ownptr_vec_diff_byref' or \ + arg_type == 'rawptr_vec_same_byref' or arg_type == 'rawptr_vec_diff_byref': result += comment+\ '\n DCHECK('+arg_name+'Count && (*'+arg_name+'Count == 0 || '+arg_name+'));'\ '\n if (!'+arg_name+'Count || (*'+arg_name+'Count > 0 && !'+arg_name+'))'\ '\n return'+retval_default+';' elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ - arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const' or \ + arg_type == 'ownptr_vec_same_byref_const' or arg_type == 'ownptr_vec_diff_byref_const' or \ + arg_type == 'rawptr_vec_same_byref_const' or arg_type == 'rawptr_vec_diff_byref_const': result += comment+\ '\n DCHECK('+arg_name+'Count == 0 || '+arg_name+');'\ '\n if ('+arg_name+'Count > 0 && !'+arg_name+')'\ @@ -184,22 +192,36 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): '\n CefString '+arg_name+'Str('+arg_name+');' params.append(arg_name+'Str') elif arg_type == 'refptr_same' or arg_type == 'refptr_diff': - refptr_class = arg.get_type().get_refptr_type() + ptr_class = arg.get_type().get_ptr_type() if arg_type == 'refptr_same': - params.append(refptr_class+'CppToC::Unwrap('+arg_name+')') + params.append(ptr_class+'CppToC::Unwrap('+arg_name+')') else: - params.append(refptr_class+'CToCpp::Wrap('+arg_name+')') - elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - if arg_type == 'refptr_same_byref': - assign = refptr_class+'CppToC::Unwrap(*'+arg_name+')' + params.append(ptr_class+'CToCpp::Wrap('+arg_name+')') + elif arg_type == 'ownptr_same' or arg_type == 'rawptr_same': + ptr_class = arg.get_type().get_ptr_type() + if arg_type == 'ownptr_same': + params.append(ptr_class+'CppToC::UnwrapOwn('+arg_name+')') else: - assign = refptr_class+'CToCpp::Wrap(*'+arg_name+')' + params.append(ptr_class+'CppToC::UnwrapRaw('+arg_name+')') + elif arg_type == 'ownptr_diff' or arg_type == 'rawptr_diff': + ptr_class = arg.get_type().get_ptr_type() result += comment+\ - '\n CefRefPtr<'+refptr_class+'> '+arg_name+'Ptr;'\ + '\n CefOwnPtr<'+ptr_class+'> '+arg_name+'Ptr('+ptr_class+'CToCpp::Wrap('+arg_name+'));' + if arg_type == 'ownptr_diff': + params.append('OWN_PASS('+arg_name+'Ptr)') + else: + params.append(arg_name+'Ptr.get()') + elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': + ptr_class = arg.get_type().get_ptr_type() + if arg_type == 'refptr_same_byref': + assign = ptr_class+'CppToC::Unwrap(*'+arg_name+')' + else: + assign = ptr_class+'CToCpp::Wrap(*'+arg_name+')' + result += comment+\ + '\n CefRefPtr<'+ptr_class+'> '+arg_name+'Ptr;'\ '\n if ('+arg_name+' && *'+arg_name+')'\ '\n '+arg_name+'Ptr = '+assign+';'\ - '\n '+refptr_class+'* '+arg_name+'Orig = '+arg_name+'Ptr.get();' + '\n '+ptr_class+'* '+arg_name+'Orig = '+arg_name+'Ptr.get();' params.append(arg_name+'Ptr') elif arg_type == 'string_vec_byref' or arg_type == 'string_vec_byref_const': result += comment+\ @@ -224,11 +246,11 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): elif arg_type == 'bool_vec_byref': assign = arg_name+'[i]?true:false' elif arg_type == 'refptr_vec_same_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CppToC::Unwrap('+arg_name+'[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CppToC::Unwrap('+arg_name+'[i])' elif arg_type == 'refptr_vec_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CToCpp::Wrap('+arg_name+'[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CToCpp::Wrap('+arg_name+'[i])' result += comment+\ '\n std::vector<'+vec_type+' > '+arg_name+'List;'\ '\n if ('+arg_name+'Count && *'+arg_name+'Count > 0 && '+arg_name+') {'\ @@ -238,18 +260,23 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): '\n }' params.append(arg_name+'List') elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ - arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const' or \ + arg_type == 'rawptr_vec_same_byref_const' or arg_type == 'rawptr_vec_diff_byref_const': vec_type = arg.get_type().get_vector_type() if arg_type == 'simple_vec_byref_const': assign = arg_name+'[i]' elif arg_type == 'bool_vec_byref_const': assign = arg_name+'[i]?true:false' - elif arg_type == 'refptr_vec_same_byref_const': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CppToC::Unwrap('+arg_name+'[i])' - elif arg_type == 'refptr_vec_diff_byref_const': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CToCpp::Wrap('+arg_name+'[i])' + else: + ptr_class = arg.get_type().get_ptr_type() + if arg_type == 'refptr_vec_same_byref_const': + assign = ptr_class+'CppToC::Unwrap('+arg_name+'[i])' + elif arg_type == 'refptr_vec_diff_byref_const': + assign = ptr_class+'CToCpp::Wrap('+arg_name+'[i])' + elif arg_type == 'rawptr_vec_same_byref_const': + assign = ptr_class+'CppToC::UnwrapRaw('+arg_name+'[i])' + elif arg_type == 'rawptr_vec_diff_byref_const': + assign = ptr_class+'CToCpp::Wrap('+arg_name+'[i]).release()' result += comment+\ '\n std::vector<'+vec_type+' > '+arg_name+'List;'\ '\n if ('+arg_name+'Count > 0) {'\ @@ -259,6 +286,8 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): '\n }'\ '\n }' params.append(arg_name+'List') + else: + raise Exception('Unsupported argument type %s for parameter %s in %s' % (arg_type, arg_name, name)) if len(result) != result_len: result += '\n' @@ -315,11 +344,11 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): '\n if ('+arg_name+')'\ '\n '+arg_name+'Obj.DetachTo(*'+arg_name+');' elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': - refptr_class = arg.get_type().get_refptr_type() + ptr_class = arg.get_type().get_ptr_type() if arg_type == 'refptr_same_byref': - assign = refptr_class+'CppToC::Wrap('+arg_name+'Ptr)' + assign = ptr_class+'CppToC::Wrap('+arg_name+'Ptr)' else: - assign = refptr_class+'CToCpp::Unwrap('+arg_name+'Ptr)' + assign = ptr_class+'CToCpp::Unwrap('+arg_name+'Ptr)' result += comment+\ '\n if ('+arg_name+') {'\ '\n if ('+arg_name+'Ptr.get()) {'\ @@ -347,11 +376,11 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): if arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref': assign = arg_name+'List[i]' elif arg_type == 'refptr_vec_same_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CppToC::Wrap('+arg_name+'List[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CppToC::Wrap('+arg_name+'List[i])' elif arg_type == 'refptr_vec_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CToCpp::Unwrap('+arg_name+'List[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CToCpp::Unwrap('+arg_name+'List[i])' result += comment+\ '\n if ('+arg_name+'Count && '+arg_name+') {'\ '\n *'+arg_name+'Count = std::min('+arg_name+'List.size(), *'+arg_name+'Count);'\ @@ -361,6 +390,13 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): '\n }'\ '\n }'\ '\n }' + elif arg_type == 'rawptr_vec_diff_byref_const': + result += comment+\ + '\n if ('+arg_name+'Count > 0) {'\ + '\n for (size_t i = 0; i < '+arg_name+'Count; ++i) {'\ + '\n delete '+arg_name+'List[i];'\ + '\n }'\ + '\n }' if len(result) != result_len: result += '\n' @@ -401,11 +437,19 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names): elif retval_type == 'string': result += '\n return _retval.DetachToUserFree();' elif retval_type == 'refptr_same': - refptr_class = retval.get_type().get_refptr_type() - result += '\n return '+refptr_class+'CppToC::Wrap(_retval);' + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CppToC::Wrap(_retval);' elif retval_type == 'refptr_diff': - refptr_class = retval.get_type().get_refptr_type() - result += '\n return '+refptr_class+'CToCpp::Unwrap(_retval);' + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CToCpp::Unwrap(_retval);' + elif retval_type == 'ownptr_same': + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CppToC::WrapOwn(OWN_PASS(_retval));' + elif retval_type == 'ownptr_diff': + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CToCpp::UnwrapOwn(OWN_PASS(_retval));' + else: + raise Exception('Unsupported return type %s in %s' % (retval_type, name)) if len(result) != result_len: result += '\n' @@ -437,7 +481,7 @@ def make_cpptoc_virtual_function_impl(header, cls, existing, prefixname, defined cur_cls = cls while True: parent_name = cur_cls.get_parent_name() - if parent_name == 'CefBase': + if is_base_class(parent_name): break else: parent_cls = header.get_class(parent_name, defined_names) @@ -463,7 +507,7 @@ def make_cpptoc_virtual_function_assignment(header, cls, prefixname, defined_nam while True: parent_name = cur_cls.get_parent_name() offset += 'base.' - if parent_name == 'CefBase': + if is_base_class(parent_name): break else: parent_cls = header.get_class(parent_name, defined_names) @@ -474,25 +518,37 @@ def make_cpptoc_virtual_function_assignment(header, cls, prefixname, defined_nam return impl -def make_cpptoc_unwrap_derived(header, cls): +def make_cpptoc_unwrap_derived(header, cls, base_scoped): # identify all classes that derive from cls derived_classes = [] - clsname = cls.get_name() + cur_clsname = cls.get_name() allclasses = header.get_classes() for cur_cls in allclasses: - if cur_cls.get_name() == clsname: + if cur_cls.get_name() == cur_clsname: continue - if cur_cls.has_parent(clsname): + if cur_cls.has_parent(cur_clsname): derived_classes.append(cur_cls.get_name()) derived_classes = sorted(derived_classes) - impl = '' - for clsname in derived_classes: - impl += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ - ' return '+clsname+'CppToC::Unwrap(reinterpret_cast<'+\ - get_capi_name(clsname, True)+'*>(s));\n'+\ - ' }\n' + if base_scoped: + impl = ['', ''] + for clsname in derived_classes: + impl[0] += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ + ' return OWN_RETURN_AS('+clsname+'CppToC::UnwrapOwn(reinterpret_cast<'+\ + get_capi_name(clsname, True)+'*>(s)), '+cur_clsname+');\n'+\ + ' }\n' + impl[1] += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ + ' return '+clsname+'CppToC::UnwrapRaw(reinterpret_cast<'+\ + get_capi_name(clsname, True)+'*>(s));\n'+\ + ' }\n' + else: + impl = '' + for clsname in derived_classes: + impl += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ + ' return '+clsname+'CppToC::Unwrap(reinterpret_cast<'+\ + get_capi_name(clsname, True)+'*>(s));\n'+\ + ' }\n' return impl def make_cpptoc_class_impl(header, clsname, impl): @@ -510,6 +566,13 @@ def make_cpptoc_class_impl(header, clsname, impl): # retrieve the existing virtual function implementations existing = get_function_impls(impl, 'CEF_CALLBACK') + base_class_name = header.get_base_class_name(clsname) + base_scoped = True if base_class_name == 'CefBaseScoped' else False + if base_scoped: + template_class = 'CefCppToCScoped' + else: + template_class = 'CefCppToC' + # generate virtual functions virtualimpl = make_cpptoc_virtual_function_impl(header, cls, existing, prefixname, defined_names) if len(virtualimpl) > 0: @@ -529,31 +592,43 @@ def make_cpptoc_class_impl(header, clsname, impl): resultingimpl = staticimpl + virtualimpl # any derived classes can be unwrapped - unwrapderived = make_cpptoc_unwrap_derived(header, cls) + unwrapderived = make_cpptoc_unwrap_derived(header, cls, base_scoped) # determine what includes are required by identifying what translation # classes are being used - includes = format_translation_includes(header, resultingimpl + unwrapderived) + includes = format_translation_includes(header, resultingimpl + (unwrapderived[0] if base_scoped else unwrapderived)) # build the final output result = get_copyright() result += includes+'\n'+resultingimpl+'\n' - parent_sig = 'CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>' + parent_sig = template_class+'<'+clsname+'CppToC, '+clsname+', '+capiname+'>' const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \ clsname+'CppToC::'+clsname+'CppToC() {\n' - const += make_cpptoc_virtual_function_assignment(header, cls, prefixname, defined_names) + const += '}\n\n' - const += '}\n\n'+ \ - 'template<> CefRefPtr<'+clsname+'> '+parent_sig+'::UnwrapDerived(CefWrapperType type, '+capiname+'* s) {\n' + \ - unwrapderived + \ - ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ - ' return NULL;\n'+ \ - '}\n\n'+ \ - '#if DCHECK_IS_ON()\n'+ \ + if base_scoped: + const += 'template<> CefOwnPtr<'+clsname+'> '+parent_sig+'::UnwrapDerivedOwn(CefWrapperType type, '+capiname+'* s) {\n' + \ + unwrapderived[0] + \ + ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ + ' return CefOwnPtr<'+clsname+'>();\n'+ \ + '}\n\n' + \ + 'template<> CefRawPtr<'+clsname+'> '+parent_sig+'::UnwrapDerivedRaw(CefWrapperType type, '+capiname+'* s) {\n' + \ + unwrapderived[1] + \ + ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ + ' return NULL;\n'+ \ + '}\n\n' + else: + const += 'template<> CefRefPtr<'+clsname+'> '+parent_sig+'::UnwrapDerived(CefWrapperType type, '+capiname+'* s) {\n' + \ + unwrapderived + \ + ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ + ' return NULL;\n'+ \ + '}\n\n' + + const += '#if DCHECK_IS_ON()\n'+ \ 'template<> base::AtomicRefCount '+parent_sig+'::DebugObjCt = 0;\n'+ \ '#endif\n\n'+ \ 'template<> CefWrapperType '+parent_sig+'::kWrapperType = '+get_wrapper_type_enum(clsname)+';' diff --git a/tools/make_ctocpp_header.py b/tools/make_ctocpp_header.py index bf68ddbc0..07922ce64 100644 --- a/tools/make_ctocpp_header.py +++ b/tools/make_ctocpp_header.py @@ -23,7 +23,7 @@ def make_function_body(header, cls): cur_cls = cls while True: parent_name = cur_cls.get_parent_name() - if parent_name == 'CefBase': + if is_base_class(parent_name): break else: parent_cls = header.get_class(parent_name) @@ -92,10 +92,17 @@ def make_ctocpp_header(header, clsname): result += '#include "include/'+dcls.get_file_name()+'"\n' \ '#include "include/capi/'+dcls.get_capi_file_name()+'"\n' - result += """#include "libcef_dll/ctocpp/ctocpp.h" + base_class_name = header.get_base_class_name(clsname) + base_scoped = True if base_class_name == 'CefBaseScoped' else False + if base_scoped: + template_file = 'ctocpp_scoped.h' + template_class = 'CefCToCppScoped' + else: + template_file = 'ctocpp.h' + template_class = 'CefCToCpp' -// Wrap a C structure with a C++ class. -""" + result += '#include "libcef_dll/ctocpp/' + template_file + '"' + result += '\n\n// Wrap a C structure with a C++ class.\n' if clientside: result += '// This class may be instantiated and accessed DLL-side only.\n' @@ -103,7 +110,7 @@ def make_ctocpp_header(header, clsname): result += '// This class may be instantiated and accessed wrapper-side only.\n' result += 'class '+clsname+'CToCpp\n'+ \ - ' : public CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'> {\n'+ \ + ' : public ' + template_class + '<'+clsname+'CToCpp, '+clsname+', '+capiname+'> {\n'+ \ ' public:\n'+ \ ' '+clsname+'CToCpp();\n\n' diff --git a/tools/make_ctocpp_impl.py b/tools/make_ctocpp_impl.py index d05df842e..050ca400c 100644 --- a/tools/make_ctocpp_impl.py +++ b/tools/make_ctocpp_impl.py @@ -117,11 +117,17 @@ def make_ctocpp_function_impl_new(clsname, name, func): '\n DCHECK('+arg_name+');'\ '\n if (!'+arg_name+')'\ '\n return'+retval_default+';' - elif arg_type == 'refptr_same' or arg_type == 'refptr_diff': + elif arg_type == 'refptr_same' or arg_type == 'refptr_diff' or \ + arg_type == 'ownptr_same' or arg_type == 'ownptr_diff': result += comment+\ '\n DCHECK('+arg_name+'.get());'\ '\n if (!'+arg_name+'.get())'\ '\n return'+retval_default+';' + elif arg_type == 'rawptr_same' or arg_type == 'rawptr_diff': + result += comment+\ + '\n DCHECK('+arg_name+');'\ + '\n if (!'+arg_name+')'\ + '\n return'+retval_default+';' elif arg_type == 'string_byref_const': result += comment+\ '\n DCHECK(!'+arg_name+'.empty());'\ @@ -181,23 +187,37 @@ def make_ctocpp_function_impl_new(clsname, name, func): elif arg_type == 'string_byref': params.append(arg_name+'.GetWritableStruct()') elif arg_type == 'refptr_same': - refptr_class = arg.get_type().get_refptr_type() - params.append(refptr_class+'CToCpp::Unwrap('+arg_name+')') + ptr_class = arg.get_type().get_ptr_type() + params.append(ptr_class+'CToCpp::Unwrap('+arg_name+')') + elif arg_type == 'ownptr_same': + ptr_class = arg.get_type().get_ptr_type() + params.append(ptr_class+'CToCpp::UnwrapOwn(OWN_PASS('+arg_name+'))') + elif arg_type == 'rawptr_same': + ptr_class = arg.get_type().get_ptr_type() + params.append(ptr_class+'CToCpp::UnwrapRaw('+arg_name+')') elif arg_type == 'refptr_diff': - refptr_class = arg.get_type().get_refptr_type() - params.append(refptr_class+'CppToC::Wrap('+arg_name+')') - elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - refptr_struct = arg.get_type().get_result_refptr_type_root() - if arg_type == 'refptr_same_byref': - assign = refptr_class+'CToCpp::Unwrap('+arg_name+')' - else: - assign = refptr_class+'CppToC::Wrap('+arg_name+')' + ptr_class = arg.get_type().get_ptr_type() + params.append(ptr_class+'CppToC::Wrap('+arg_name+')') + elif arg_type == 'ownptr_diff': + ptr_class = arg.get_type().get_ptr_type() + params.append(ptr_class+'CppToC::WrapOwn(OWN_PASS('+arg_name+'))') + elif arg_type == 'rawptr_diff': + ptr_class = arg.get_type().get_ptr_type() result += comment+\ - '\n '+refptr_struct+'* '+arg_name+'Struct = NULL;'\ + '\n CefOwnPtr<'+ptr_class+'CppToC> '+arg_name+'Ptr('+ptr_class+'CppToC::WrapRaw('+arg_name+'));' + params.append(arg_name+'Ptr->GetStruct()') + elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': + ptr_class = arg.get_type().get_ptr_type() + ptr_struct = arg.get_type().get_result_ptr_type_root() + if arg_type == 'refptr_same_byref': + assign = ptr_class+'CToCpp::Unwrap('+arg_name+')' + else: + assign = ptr_class+'CppToC::Wrap('+arg_name+')' + result += comment+\ + '\n '+ptr_struct+'* '+arg_name+'Struct = NULL;'\ '\n if ('+arg_name+'.get())'\ '\n '+arg_name+'Struct = '+assign+';'\ - '\n '+refptr_struct+'* '+arg_name+'Orig = '+arg_name+'Struct;' + '\n '+ptr_struct+'* '+arg_name+'Orig = '+arg_name+'Struct;' params.append('&'+arg_name+'Struct') elif arg_type == 'string_vec_byref' or arg_type == 'string_vec_byref_const': result += comment+\ @@ -225,11 +245,11 @@ def make_ctocpp_function_impl_new(clsname, name, func): count_func = arg.get_attrib_count_func() vec_type = arg.get_type().get_result_vector_type_root() if arg_type == 'refptr_vec_same_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CToCpp::Unwrap('+arg_name+'[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CToCpp::Unwrap('+arg_name+'[i])' elif arg_type == 'refptr_vec_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CppToC::Wrap('+arg_name+'[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CppToC::Wrap('+arg_name+'[i])' else: assign = arg_name+'[i]' result += comment+\ @@ -251,17 +271,22 @@ def make_ctocpp_function_impl_new(clsname, name, func): params.append('&'+arg_name+'Count') params.append(arg_name+'List') elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ - arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const' or \ + arg_type == 'rawptr_vec_same_byref_const' or arg_type == 'rawptr_vec_diff_byref_const': count_func = arg.get_attrib_count_func() vec_type = arg.get_type().get_result_vector_type_root() - if arg_type == 'refptr_vec_same_byref_const': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CToCpp::Unwrap('+arg_name+'[i])' - elif arg_type == 'refptr_vec_diff_byref_const': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CppToC::Wrap('+arg_name+'[i])' - else: + if arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const': assign = arg_name+'[i]' + else: + ptr_class = arg.get_type().get_ptr_type() + if arg_type == 'refptr_vec_same_byref_const': + assign = ptr_class+'CToCpp::Unwrap('+arg_name+'[i])' + elif arg_type == 'refptr_vec_diff_byref_const': + assign = ptr_class+'CppToC::Wrap('+arg_name+'[i])' + elif arg_type == 'rawptr_vec_same_byref_const': + assign = ptr_class+'CToCpp::UnwrapRaw('+arg_name+'[i])' + elif arg_type == 'rawptr_vec_diff_byref_const': + assign = ptr_class+'CppToC::WrapRaw('+arg_name+'[i]).release()->GetStruct()' result += comment+\ '\n const size_t '+arg_name+'Count = '+arg_name+'.size();'\ '\n '+vec_type+'* '+arg_name+'List = NULL;'\ @@ -276,6 +301,8 @@ def make_ctocpp_function_impl_new(clsname, name, func): '\n }' params.append(arg_name+'Count') params.append(arg_name+'List') + else: + raise Exception('Unsupported argument type %s for parameter %s in %s' % (arg_type, arg_name, name)) if len(result) != result_len: result += '\n' @@ -290,9 +317,12 @@ def make_ctocpp_function_impl_new(clsname, name, func): result += retval.get_type().get_result_simple_type_root() elif retval_type == 'string': result += 'cef_string_userfree_t' - elif retval_type == 'refptr_same' or retval_type == 'refptr_diff': - refptr_struct = retval.get_type().get_result_refptr_type_root() - result += refptr_struct+'*' + elif retval_type == 'refptr_same' or retval_type == 'refptr_diff' or \ + retval_type == 'ownptr_same' or retval_type == 'ownptr_diff': + ptr_struct = retval.get_type().get_result_ptr_type_root() + result += ptr_struct+'*' + else: + raise Exception('Unsupported return type %s in %s' % (retval_type, name)) result += ' _retval = ' @@ -324,12 +354,12 @@ def make_ctocpp_function_impl_new(clsname, name, func): '\n if ('+arg_name+')'\ '\n *'+arg_name+' = '+arg_name+'Int?true:false;' elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - refptr_struct = arg.get_type().get_result_refptr_type_root() + ptr_class = arg.get_type().get_ptr_type() + ptr_struct = arg.get_type().get_result_ptr_type_root() if arg_type == 'refptr_same_byref': - assign = refptr_class+'CToCpp::Wrap('+arg_name+'Struct)' + assign = ptr_class+'CToCpp::Wrap('+arg_name+'Struct)' else: - assign = refptr_class+'CppToC::Unwrap('+arg_name+'Struct)' + assign = ptr_class+'CppToC::Unwrap('+arg_name+'Struct)' result += comment+\ '\n if ('+arg_name+'Struct) {'\ '\n if ('+arg_name+'Struct != '+arg_name+'Orig) {'\ @@ -376,11 +406,11 @@ def make_ctocpp_function_impl_new(clsname, name, func): count_func = arg.get_attrib_count_func() vec_type = arg.get_type().get_result_vector_type_root() if arg_type == 'refptr_vec_same_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CToCpp::Wrap('+arg_name+'List[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CToCpp::Wrap('+arg_name+'List[i])' elif arg_type == 'refptr_vec_diff_byref': - refptr_class = arg.get_type().get_refptr_type() - assign = refptr_class+'CppToC::Unwrap('+arg_name+'List[i])' + ptr_class = arg.get_type().get_ptr_type() + assign = ptr_class+'CppToC::Unwrap('+arg_name+'List[i])' elif arg_type == 'bool_vec_byref': assign = arg_name+'List[i]?true:false' else: @@ -394,9 +424,16 @@ def make_ctocpp_function_impl_new(clsname, name, func): '\n delete [] '+arg_name+'List;'\ '\n }' elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ - arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': - result += comment+\ - '\n if ('+arg_name+'List)'\ + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const' or \ + arg_type == 'rawptr_vec_same_byref_const' or arg_type == 'rawptr_vec_diff_byref_const': + result += comment + if arg_type == 'rawptr_vec_diff_byref_const': + result += '\n if ('+arg_name+'Count > 0) {'\ + '\n for (size_t i = 0; i < '+arg_name+'Count; ++i) {'\ + '\n delete '+ptr_class+'CppToC::GetWrapper('+arg_name+'List[i]);'\ + '\n }'\ + '\n }' + result += '\n if ('+arg_name+'List)'\ '\n delete [] '+arg_name+'List;' if len(result) != result_len: @@ -441,12 +478,17 @@ def make_ctocpp_function_impl_new(clsname, name, func): result += '\n CefString _retvalStr;'\ '\n _retvalStr.AttachToUserFree(_retval);'\ '\n return _retvalStr;' - elif retval_type == 'refptr_same': - refptr_class = retval.get_type().get_refptr_type() - result += '\n return '+refptr_class+'CToCpp::Wrap(_retval);' + elif retval_type == 'refptr_same' or retval_type == 'ownptr_same': + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CToCpp::Wrap(_retval);' elif retval_type == 'refptr_diff': - refptr_class = retval.get_type().get_refptr_type() - result += '\n return '+refptr_class+'CppToC::Unwrap(_retval);' + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CppToC::Unwrap(_retval);' + elif retval_type == 'ownptr_diff': + ptr_class = retval.get_type().get_ptr_type() + result += '\n return '+ptr_class+'CppToC::UnwrapOwn(_retval);' + else: + raise Exception('Unsupported return type %s in %s' % (retval_type, name)) if len(result) != result_len: result += '\n' @@ -475,7 +517,7 @@ def make_ctocpp_virtual_function_impl(header, cls, existing): cur_cls = cls while True: parent_name = cur_cls.get_parent_name() - if parent_name == 'CefBase': + if is_base_class(parent_name): break else: parent_cls = header.get_class(parent_name) @@ -486,7 +528,7 @@ def make_ctocpp_virtual_function_impl(header, cls, existing): return impl -def make_ctocpp_unwrap_derived(header, cls): +def make_ctocpp_unwrap_derived(header, cls, base_scoped): # identify all classes that derive from cls derived_classes = [] clsname = cls.get_name() @@ -499,12 +541,24 @@ def make_ctocpp_unwrap_derived(header, cls): derived_classes = sorted(derived_classes) - impl = '' - for clsname in derived_classes: - impl += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ - ' return reinterpret_cast<'+get_capi_name(cls.get_name(), True)+'*>('+\ - clsname+'CToCpp::Unwrap(reinterpret_cast<'+clsname+'*>(c)));\n'+\ - ' }\n' + if base_scoped: + impl = ['', ''] + for clsname in derived_classes: + impl[0] += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ + ' return reinterpret_cast<'+get_capi_name(cls.get_name(), True)+'*>('+\ + clsname+'CToCpp::UnwrapOwn(CefOwnPtr<'+clsname+'>(reinterpret_cast<'+clsname+'*>(c.release()))));\n'+\ + ' }\n' + impl[1] += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ + ' return reinterpret_cast<'+get_capi_name(cls.get_name(), True)+'*>('+\ + clsname+'CToCpp::UnwrapRaw(CefRawPtr<'+clsname+'>(reinterpret_cast<'+clsname+'*>(c))));\n'+\ + ' }\n' + else: + impl = '' + for clsname in derived_classes: + impl += ' if (type == '+get_wrapper_type_enum(clsname)+') {\n'+\ + ' return reinterpret_cast<'+get_capi_name(cls.get_name(), True)+'*>('+\ + clsname+'CToCpp::Unwrap(reinterpret_cast<'+clsname+'*>(c)));\n'+\ + ' }\n' return impl def make_ctocpp_class_impl(header, clsname, impl): @@ -517,6 +571,13 @@ def make_ctocpp_class_impl(header, clsname, impl): # retrieve the existing virtual function implementations existing = get_function_impls(impl, clsname+'CToCpp::') + base_class_name = header.get_base_class_name(clsname) + base_scoped = True if base_class_name == 'CefBaseScoped' else False + if base_scoped: + template_class = 'CefCToCppScoped' + else: + template_class = 'CefCToCpp' + # generate virtual functions virtualimpl = make_ctocpp_virtual_function_impl(header, cls, existing) if len(virtualimpl) > 0: @@ -533,28 +594,42 @@ def make_ctocpp_class_impl(header, clsname, impl): resultingimpl = staticimpl + virtualimpl # any derived classes can be unwrapped - unwrapderived = make_ctocpp_unwrap_derived(header, cls) + unwrapderived = make_ctocpp_unwrap_derived(header, cls, base_scoped) # determine what includes are required by identifying what translation # classes are being used - includes = format_translation_includes(header, resultingimpl + unwrapderived) + includes = format_translation_includes(header, resultingimpl + (unwrapderived[0] if base_scoped else unwrapderived)) # build the final output result = get_copyright() result += includes+'\n'+resultingimpl+'\n' - parent_sig = 'CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>' + parent_sig = template_class+'<'+clsname+'CToCpp, '+clsname+', '+capiname+'>' const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \ clsname+'CToCpp::'+clsname+'CToCpp() {\n'+ \ - '}\n\n'+ \ - 'template<> '+capiname+'* '+parent_sig+'::UnwrapDerived(CefWrapperType type, '+clsname+'* c) {\n'+ \ - unwrapderived + \ - ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ - ' return NULL;\n'+ \ - '}\n\n'+ \ - '#if DCHECK_IS_ON()\n'+ \ + '}\n\n' + + if base_scoped: + const += 'template<> '+capiname+'* '+parent_sig+'::UnwrapDerivedOwn(CefWrapperType type, CefOwnPtr<'+clsname+'> c) {\n'+ \ + unwrapderived[0] + \ + ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ + ' return NULL;\n'+ \ + '}\n\n' + \ + 'template<> '+capiname+'* '+parent_sig+'::UnwrapDerivedRaw(CefWrapperType type, CefRawPtr<'+clsname+'> c) {\n'+ \ + unwrapderived[1] + \ + ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ + ' return NULL;\n'+ \ + '}\n\n' + else: + const += 'template<> '+capiname+'* '+parent_sig+'::UnwrapDerived(CefWrapperType type, '+clsname+'* c) {\n'+ \ + unwrapderived + \ + ' NOTREACHED() << "Unexpected class type: " << type;\n'+ \ + ' return NULL;\n'+ \ + '}\n\n' + + const += '#if DCHECK_IS_ON()\n'+ \ 'template<> base::AtomicRefCount '+parent_sig+'::DebugObjCt = 0;\n'+ \ '#endif\n\n'+ \ 'template<> CefWrapperType '+parent_sig+'::kWrapperType = '+get_wrapper_type_enum(clsname)+';'