Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WebIDL generator should support the possibility for C++ classes to ha…
…ve a JS Builtin constructor https://bugs.webkit.org/show_bug.cgi?id=152171 Reviewed by Darin Adler. Reintroducing JSBuiltinConstructor keyword as a way to run automatically a JS builtin initialization function to process the arguments passed to the DOM C++ constructor. Specialized createJSObject for those classes. Fixing typo in TestCustomConstructor.idl. Covered by binding tests. * bindings/scripts/CodeGeneratorJS.pm: (GenerateConstructorDefinition): (IsConstructable): (IsJSBuiltinConstructor): (AddJSBuiltinIncludesIfNeeded): * bindings/scripts/test/GObject/WebKitDOMTestClassWithJSBuiltinConstructor.cpp: Added. * bindings/scripts/test/GObject/WebKitDOMTestClassWithJSBuiltinConstructor.h: Added. * bindings/scripts/test/GObject/WebKitDOMTestClassWithJSBuiltinConstructorPrivate.h: Added. * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp: Added. * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h: Added. * bindings/scripts/test/ObjC/DOMTestClassWithJSBuiltinConstructor.h: Added. * bindings/scripts/test/ObjC/DOMTestClassWithJSBuiltinConstructor.mm: Added. * bindings/scripts/test/ObjC/DOMTestClassWithJSBuiltinConstructorInternal.h: Added. * bindings/scripts/test/TestClassWithJSBuiltinConstructor.idl: Copied from Source/WebCore/bindings/scripts/test/TestCustomConstructor.idl. * bindings/scripts/test/TestCustomConstructor.idl: Canonical link: https://commits.webkit.org/170407@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
702 additions
and 5 deletions.
- +32 −0 Source/WebCore/ChangeLog
- +17 −3 Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
- +104 −0 Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestClassWithJSBuiltinConstructor.cpp
- +53 −0 Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestClassWithJSBuiltinConstructor.h
- +33 −0 Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestClassWithJSBuiltinConstructorPrivate.h
- +206 −0 Source/WebCore/bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp
- +85 −0 Source/WebCore/bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h
- +31 −0 Source/WebCore/bindings/scripts/test/ObjC/DOMTestClassWithJSBuiltinConstructor.h
- +75 −0 Source/WebCore/bindings/scripts/test/ObjC/DOMTestClassWithJSBuiltinConstructor.mm
- +34 −0 Source/WebCore/bindings/scripts/test/ObjC/DOMTestClassWithJSBuiltinConstructorInternal.h
- +32 −0 Source/WebCore/bindings/scripts/test/TestClassWithJSBuiltinConstructor.idl
- +0 −2 Source/WebCore/bindings/scripts/test/TestCustomConstructor.idl
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,104 @@ | ||
/* | ||
* This file is part of the WebKit open source project. | ||
* This file has been generated by generate-bindings.pl. DO NOT MODIFY! | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public License | ||
* along with this library; see the file COPYING.LIB. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "WebKitDOMTestClassWithJSBuiltinConstructor.h" | ||
|
||
#include "CSSImportRule.h" | ||
#include "DOMObjectCache.h" | ||
#include "Document.h" | ||
#include "ExceptionCode.h" | ||
#include "ExceptionCodeDescription.h" | ||
#include "JSMainThreadExecState.h" | ||
#include "WebKitDOMPrivate.h" | ||
#include "WebKitDOMTestClassWithJSBuiltinConstructorPrivate.h" | ||
#include "gobject/ConvertToUTF8String.h" | ||
#include <wtf/GetPtr.h> | ||
#include <wtf/RefPtr.h> | ||
|
||
#define WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR, WebKitDOMTestClassWithJSBuiltinConstructorPrivate) | ||
|
||
typedef struct _WebKitDOMTestClassWithJSBuiltinConstructorPrivate { | ||
RefPtr<WebCore::TestClassWithJSBuiltinConstructor> coreObject; | ||
} WebKitDOMTestClassWithJSBuiltinConstructorPrivate; | ||
|
||
namespace WebKit { | ||
|
||
WebKitDOMTestClassWithJSBuiltinConstructor* kit(WebCore::TestClassWithJSBuiltinConstructor* obj) | ||
{ | ||
if (!obj) | ||
return 0; | ||
|
||
if (gpointer ret = DOMObjectCache::get(obj)) | ||
return WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR(ret); | ||
|
||
return wrapTestClassWithJSBuiltinConstructor(obj); | ||
} | ||
|
||
WebCore::TestClassWithJSBuiltinConstructor* core(WebKitDOMTestClassWithJSBuiltinConstructor* request) | ||
{ | ||
return request ? static_cast<WebCore::TestClassWithJSBuiltinConstructor*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0; | ||
} | ||
|
||
WebKitDOMTestClassWithJSBuiltinConstructor* wrapTestClassWithJSBuiltinConstructor(WebCore::TestClassWithJSBuiltinConstructor* coreObject) | ||
{ | ||
ASSERT(coreObject); | ||
return WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR(g_object_new(WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR, "core-object", coreObject, nullptr)); | ||
} | ||
|
||
} // namespace WebKit | ||
|
||
G_DEFINE_TYPE(WebKitDOMTestClassWithJSBuiltinConstructor, webkit_dom_test_class_with_js_builtin_constructor, WEBKIT_DOM_TYPE_OBJECT) | ||
|
||
static void webkit_dom_test_class_with_js_builtin_constructor_finalize(GObject* object) | ||
{ | ||
WebKitDOMTestClassWithJSBuiltinConstructorPrivate* priv = WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_GET_PRIVATE(object); | ||
|
||
WebKit::DOMObjectCache::forget(priv->coreObject.get()); | ||
|
||
priv->~WebKitDOMTestClassWithJSBuiltinConstructorPrivate(); | ||
G_OBJECT_CLASS(webkit_dom_test_class_with_js_builtin_constructor_parent_class)->finalize(object); | ||
} | ||
|
||
static GObject* webkit_dom_test_class_with_js_builtin_constructor_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties) | ||
{ | ||
GObject* object = G_OBJECT_CLASS(webkit_dom_test_class_with_js_builtin_constructor_parent_class)->constructor(type, constructPropertiesCount, constructProperties); | ||
|
||
WebKitDOMTestClassWithJSBuiltinConstructorPrivate* priv = WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_GET_PRIVATE(object); | ||
priv->coreObject = static_cast<WebCore::TestClassWithJSBuiltinConstructor*>(WEBKIT_DOM_OBJECT(object)->coreObject); | ||
WebKit::DOMObjectCache::put(priv->coreObject.get(), object); | ||
|
||
return object; | ||
} | ||
|
||
static void webkit_dom_test_class_with_js_builtin_constructor_class_init(WebKitDOMTestClassWithJSBuiltinConstructorClass* requestClass) | ||
{ | ||
GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); | ||
g_type_class_add_private(gobjectClass, sizeof(WebKitDOMTestClassWithJSBuiltinConstructorPrivate)); | ||
gobjectClass->constructor = webkit_dom_test_class_with_js_builtin_constructor_constructor; | ||
gobjectClass->finalize = webkit_dom_test_class_with_js_builtin_constructor_finalize; | ||
} | ||
|
||
static void webkit_dom_test_class_with_js_builtin_constructor_init(WebKitDOMTestClassWithJSBuiltinConstructor* request) | ||
{ | ||
WebKitDOMTestClassWithJSBuiltinConstructorPrivate* priv = WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_GET_PRIVATE(request); | ||
new (priv) WebKitDOMTestClassWithJSBuiltinConstructorPrivate(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,53 @@ | ||
/* | ||
* This file is part of the WebKit open source project. | ||
* This file has been generated by generate-bindings.pl. DO NOT MODIFY! | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public License | ||
* along with this library; see the file COPYING.LIB. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef WebKitDOMTestClassWithJSBuiltinConstructor_h | ||
#define WebKitDOMTestClassWithJSBuiltinConstructor_h | ||
|
||
#ifdef WEBKIT_DOM_USE_UNSTABLE_API | ||
|
||
#include <glib-object.h> | ||
#include <webkitdom/WebKitDOMObject.h> | ||
#include <webkitdom/webkitdomdefines-unstable.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR (webkit_dom_test_class_with_js_builtin_constructor_get_type()) | ||
#define WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR, WebKitDOMTestClassWithJSBuiltinConstructor)) | ||
#define WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR, WebKitDOMTestClassWithJSBuiltinConstructorClass) | ||
#define WEBKIT_DOM_IS_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR)) | ||
#define WEBKIT_DOM_IS_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR)) | ||
#define WEBKIT_DOM_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_DOM_TYPE_TEST_CLASS_WITH_JS_BUILTIN_CONSTRUCTOR, WebKitDOMTestClassWithJSBuiltinConstructorClass)) | ||
|
||
struct _WebKitDOMTestClassWithJSBuiltinConstructor { | ||
WebKitDOMObject parent_instance; | ||
}; | ||
|
||
struct _WebKitDOMTestClassWithJSBuiltinConstructorClass { | ||
WebKitDOMObjectClass parent_class; | ||
}; | ||
|
||
WEBKIT_API GType | ||
webkit_dom_test_class_with_js_builtin_constructor_get_type(void); | ||
|
||
G_END_DECLS | ||
|
||
#endif /* WEBKIT_DOM_USE_UNSTABLE_API */ | ||
#endif /* WebKitDOMTestClassWithJSBuiltinConstructor_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,33 @@ | ||
/* | ||
* This file is part of the WebKit open source project. | ||
* This file has been generated by generate-bindings.pl. DO NOT MODIFY! | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public License | ||
* along with this library; see the file COPYING.LIB. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef WebKitDOMTestClassWithJSBuiltinConstructorPrivate_h | ||
#define WebKitDOMTestClassWithJSBuiltinConstructorPrivate_h | ||
|
||
#include "TestClassWithJSBuiltinConstructor.h" | ||
#include <webkitdom/WebKitDOMTestClassWithJSBuiltinConstructor.h> | ||
|
||
namespace WebKit { | ||
WebKitDOMTestClassWithJSBuiltinConstructor* wrapTestClassWithJSBuiltinConstructor(WebCore::TestClassWithJSBuiltinConstructor*); | ||
WebKitDOMTestClassWithJSBuiltinConstructor* kit(WebCore::TestClassWithJSBuiltinConstructor*); | ||
WebCore::TestClassWithJSBuiltinConstructor* core(WebKitDOMTestClassWithJSBuiltinConstructor*); | ||
} // namespace WebKit | ||
|
||
#endif /* WebKitDOMTestClassWithJSBuiltinConstructorPrivate_h */ |
Oops, something went wrong.