Skip to content
Permalink
Browse files
2010-01-28 Kavita Kanetkar <kkanetkar@chromium.org>
        Reviewed by Dimitri Glazkov.

        [V8] Generate header declaration for custom constructor callbacks
        https://bugs.webkit.org/show_bug.cgi?id=33680

        Added handling of 'CanBeConstructed' and 'OmitConstructor' and a new extended attribute
        CustomConstructor'.

        Deleted implementation .cpp files for corresponding 'CanBeConstructed'
        extended attributes. These are now generated via CodeGeneratorV8.pm
        Treating 'OmitConstructor' and 'CustomConstructor' to be the same in
        CodeGeneratorJS.pm
        Cleaned idls that had 'CustomConstructor' and 'OmitConstructor' together, and
        same with CustomConstructor and CanBeConstructed.

        * Android.v8bindings.mk:
        * WebCore.gypi: Removed deps for classes being generated.
        * bindings/scripts/CodeGeneratorJS.pm: OmitConstructor and CustomConstructor have the same behavior in generator.
        * bindings/scripts/CodeGeneratorV8.pm: Generating the callbacks for constructors.
        * bindings/v8/V8DOMWrapper.cpp: Removed manual calls to SetCallHandler() for constructor callbacks.
        (WebCore::V8DOMWrapper::getTemplate):
        * bindings/v8/custom/V8CustomBinding.h: Removed manual declarations of constructor callbacks.
        * bindings/v8/custom/V8DOMParserConstructor.cpp:
        * bindings/v8/custom/V8EventSourceConstructor.cpp:
        (WebCore::V8EventSource::constructorCallback):
        * bindings/v8/custom/V8MessageChannelConstructor.cpp:
        (WebCore::V8MessageChannel::constructorCallback):
        * bindings/v8/custom/V8SharedWorkerCustom.cpp:
        (WebCore::V8SharedWorker::constructorCallback):
        * bindings/v8/custom/V8WebGLArrayBufferCustom.cpp:
        (WebCore::V8WebGLArrayBuffer::constructorCallback):
        * bindings/v8/custom/V8WebGLByteArrayCustom.cpp:
        (WebCore::V8WebGLByteArray::constructorCallback):
        * bindings/v8/custom/V8WebGLFloatArrayCustom.cpp:
        (WebCore::V8WebGLFloatArray::constructorCallback):
        * bindings/v8/custom/V8WebGLIntArrayCustom.cpp:
        (WebCore::V8WebGLIntArray::constructorCallback):
        * bindings/v8/custom/V8WebGLShortArrayCustom.cpp:
        (WebCore::V8WebGLShortArray::constructorCallback):
        * bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp:
        (WebCore::V8WebGLUnsignedByteArray::constructorCallback):
        * bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp:
        (WebCore::V8WebGLUnsignedIntArray::constructorCallback):
        * bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp:
        (WebCore::V8WebGLUnsignedShortArray::constructorCallback):
        * bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp:
        (WebCore::V8WebKitCSSMatrix::constructorCallback):
        * bindings/v8/custom/V8WebKitPointConstructor.cpp:
        (WebCore::V8WebKitPoint::constructorCallback):
        * bindings/v8/custom/V8WebSocketCustom.cpp:
        (WebCore::V8WebSocket::constructorCallback):
        * bindings/v8/custom/V8WorkerCustom.cpp:
        (WebCore::V8Worker::constructorCallback):
        * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
        (WebCore::V8XMLHttpRequest::constructorCallback):
        * bindings/v8/custom/V8XMLSerializerConstructor.cpp:
        * bindings/v8/custom/V8XPathEvaluatorConstructor.cpp: Deleted the file. Implementation now being generated.
        * bindings/v8/custom/V8XSLTProcessorCustom.cpp: Deleted the file. Implementation now being generated.
        (WebCore::V8XSLTProcessor::constructorCallback): Deleted the file. Implementation now being generated.
        * css/WebKitCSSMatrix.idl: Added CustomConstructor attribute.
        * dom/MessageChannel.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLArrayBuffer.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLByteArray.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLFloatArray.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLIntArray.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLShortArray.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLUnsignedByteArray.idl: Added CustomConstructor attribute.
        * html/canvas/WebGLUnsignedIntArray.idl: Added CustomConstructor attribute.

Canonical link: https://commits.webkit.org/45409@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@54042 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Jan 29, 2010
1 parent c46f123 commit 4a355424f915d649d69910c2851128530ae30a1f
Showing 44 changed files with 149 additions and 321 deletions.
@@ -101,7 +101,6 @@ LOCAL_SRC_FILES += \
bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp \
bindings/v8/custom/V8CustomVoidCallback.cpp \
bindings/v8/custom/V8DOMApplicationCacheCustom.cpp \
bindings/v8/custom/V8DOMParserConstructor.cpp \
bindings/v8/custom/V8DOMWindowCustom.cpp \
bindings/v8/custom/V8DataGridColumnListCustom.cpp \
bindings/v8/custom/V8DatabaseCustom.cpp \
@@ -163,8 +162,7 @@ LOCAL_SRC_FILES += \
bindings/v8/custom/V8WorkerCustom.cpp \
bindings/v8/custom/V8XMLHttpRequestConstructor.cpp \
bindings/v8/custom/V8XMLHttpRequestCustom.cpp \
bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp \
bindings/v8/custom/V8XMLSerializerConstructor.cpp
bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp

LOCAL_SRC_FILES += \
bridge/jni/JNIUtility.cpp
@@ -1,3 +1,74 @@
2010-01-28 Kavita Kanetkar <kkanetkar@chromium.org>

Reviewed by Dimitri Glazkov.

[V8] Generate header declaration for custom constructor callbacks
https://bugs.webkit.org/show_bug.cgi?id=33680

Added handling of 'CanBeConstructed' and 'OmitConstructor' and a new extended attribute
CustomConstructor'.

Deleted implementation .cpp files for corresponding 'CanBeConstructed'
extended attributes. These are now generated via CodeGeneratorV8.pm
Treating 'OmitConstructor' and 'CustomConstructor' to be the same in
CodeGeneratorJS.pm
Cleaned idls that had 'CustomConstructor' and 'OmitConstructor' together, and
same with CustomConstructor and CanBeConstructed.

* Android.v8bindings.mk:
* WebCore.gypi: Removed deps for classes being generated.
* bindings/scripts/CodeGeneratorJS.pm: OmitConstructor and CustomConstructor have the same behavior in generator.
* bindings/scripts/CodeGeneratorV8.pm: Generating the callbacks for constructors.
* bindings/v8/V8DOMWrapper.cpp: Removed manual calls to SetCallHandler() for constructor callbacks.
(WebCore::V8DOMWrapper::getTemplate):
* bindings/v8/custom/V8CustomBinding.h: Removed manual declarations of constructor callbacks.
* bindings/v8/custom/V8DOMParserConstructor.cpp:
* bindings/v8/custom/V8EventSourceConstructor.cpp:
(WebCore::V8EventSource::constructorCallback):
* bindings/v8/custom/V8MessageChannelConstructor.cpp:
(WebCore::V8MessageChannel::constructorCallback):
* bindings/v8/custom/V8SharedWorkerCustom.cpp:
(WebCore::V8SharedWorker::constructorCallback):
* bindings/v8/custom/V8WebGLArrayBufferCustom.cpp:
(WebCore::V8WebGLArrayBuffer::constructorCallback):
* bindings/v8/custom/V8WebGLByteArrayCustom.cpp:
(WebCore::V8WebGLByteArray::constructorCallback):
* bindings/v8/custom/V8WebGLFloatArrayCustom.cpp:
(WebCore::V8WebGLFloatArray::constructorCallback):
* bindings/v8/custom/V8WebGLIntArrayCustom.cpp:
(WebCore::V8WebGLIntArray::constructorCallback):
* bindings/v8/custom/V8WebGLShortArrayCustom.cpp:
(WebCore::V8WebGLShortArray::constructorCallback):
* bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp:
(WebCore::V8WebGLUnsignedByteArray::constructorCallback):
* bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp:
(WebCore::V8WebGLUnsignedIntArray::constructorCallback):
* bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp:
(WebCore::V8WebGLUnsignedShortArray::constructorCallback):
* bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp:
(WebCore::V8WebKitCSSMatrix::constructorCallback):
* bindings/v8/custom/V8WebKitPointConstructor.cpp:
(WebCore::V8WebKitPoint::constructorCallback):
* bindings/v8/custom/V8WebSocketCustom.cpp:
(WebCore::V8WebSocket::constructorCallback):
* bindings/v8/custom/V8WorkerCustom.cpp:
(WebCore::V8Worker::constructorCallback):
* bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
(WebCore::V8XMLHttpRequest::constructorCallback):
* bindings/v8/custom/V8XMLSerializerConstructor.cpp:
* bindings/v8/custom/V8XPathEvaluatorConstructor.cpp: Deleted the file. Implementation now being generated.
* bindings/v8/custom/V8XSLTProcessorCustom.cpp: Deleted the file. Implementation now being generated.
(WebCore::V8XSLTProcessor::constructorCallback): Deleted the file. Implementation now being generated.
* css/WebKitCSSMatrix.idl: Added CustomConstructor attribute.
* dom/MessageChannel.idl: Added CustomConstructor attribute.
* html/canvas/WebGLArrayBuffer.idl: Added CustomConstructor attribute.
* html/canvas/WebGLByteArray.idl: Added CustomConstructor attribute.
* html/canvas/WebGLFloatArray.idl: Added CustomConstructor attribute.
* html/canvas/WebGLIntArray.idl: Added CustomConstructor attribute.
* html/canvas/WebGLShortArray.idl: Added CustomConstructor attribute.
* html/canvas/WebGLUnsignedByteArray.idl: Added CustomConstructor attribute.
* html/canvas/WebGLUnsignedIntArray.idl: Added CustomConstructor attribute.

2010-01-28 Steve Block <steveblock@google.com>

Reviewed by David Levin.
@@ -689,7 +689,6 @@
'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp',
'bindings/v8/custom/V8DocumentLocationCustom.cpp',
'bindings/v8/custom/V8DOMApplicationCacheCustom.cpp',
'bindings/v8/custom/V8DOMParserConstructor.cpp',
'bindings/v8/custom/V8DOMWindowCustom.cpp',
'bindings/v8/custom/V8DocumentCustom.cpp',
'bindings/v8/custom/V8ElementCustom.cpp',
@@ -752,8 +751,6 @@
'bindings/v8/custom/V8XMLHttpRequestConstructor.cpp',
'bindings/v8/custom/V8XMLHttpRequestCustom.cpp',
'bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp',
'bindings/v8/custom/V8XMLSerializerConstructor.cpp',
'bindings/v8/custom/V8XPathEvaluatorConstructor.cpp',
'bindings/v8/custom/V8XSLTProcessorCustom.cpp',
'bindings/v8/DateExtension.cpp',
'bindings/v8/DateExtension.h',
@@ -552,7 +552,8 @@ sub GenerateHeader
$implIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"} || $dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"};

my $hasGetter = $numAttributes > 0
|| !$dataNode->extendedAttributes->{"OmitConstructor"}
|| !($dataNode->extendedAttributes->{"OmitConstructor"}
|| $dataNode->extendedAttributes->{"CustomConstructor"})
|| $dataNode->extendedAttributes->{"HasIndexGetter"}
|| $dataNode->extendedAttributes->{"HasCustomIndexGetter"}
|| $dataNode->extendedAttributes->{"HasNumericIndexGetter"}
@@ -655,7 +656,7 @@ sub GenerateHeader
}

# Constructor object getter
push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if !$dataNode->extendedAttributes->{"OmitConstructor"};
push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}));

my $numCustomFunctions = 0;
my $numCustomAttributes = 0;
@@ -838,7 +839,7 @@ sub GenerateHeader
}
}

if ($numAttributes > 0 || !$dataNode->extendedAttributes->{"OmitConstructor"}) {
if ($numAttributes > 0 || !($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
push(@headerContent,"// Attributes\n\n");
foreach my $attribute (@{$dataNode->attributes}) {
my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
@@ -849,7 +850,7 @@ sub GenerateHeader
}
}

if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
my $getter = "js" . $interfaceName . "Constructor";
push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&);\n");
}
@@ -918,7 +919,7 @@ sub GenerateImplementation

# - Add all attributes in a hashtable definition
my $numAttributes = @{$dataNode->attributes};
$numAttributes++ if !$dataNode->extendedAttributes->{"OmitConstructor"};
$numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}));

if ($numAttributes > 0) {
my $hashSize = $numAttributes;
@@ -959,7 +960,7 @@ sub GenerateImplementation
}
}

if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
push(@hashKeys, "constructor");
my $getter = "js" . $interfaceName . "Constructor";
push(@hashValue1, $getter);
@@ -977,7 +978,7 @@ sub GenerateImplementation
my $numFunctions = @{$dataNode->functions};

# - Add all constants
if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
$hashSize = $numConstants;
$hashName = $className . "ConstructorTable";

@@ -1213,7 +1214,8 @@ sub GenerateImplementation
}

my $hasGetter = $numAttributes > 0
|| !$dataNode->extendedAttributes->{"OmitConstructor"}
|| !($dataNode->extendedAttributes->{"OmitConstructor"}
|| $dataNode->extendedAttributes->{"CustomConstructor"})
|| $dataNode->extendedAttributes->{"HasIndexGetter"}
|| $dataNode->extendedAttributes->{"HasCustomIndexGetter"}
|| $dataNode->extendedAttributes->{"HasNumericIndexGetter"}
@@ -1364,7 +1366,7 @@ sub GenerateImplementation
push(@implContent, "\n");
}

if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
my $constructorFunctionName = "js" . $interfaceName . "Constructor";

push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n");
@@ -1505,7 +1507,7 @@ sub GenerateImplementation
push(@implContent, "}\n\n");
}

if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n");
push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));\n");
push(@implContent, "}\n\n");
@@ -299,6 +299,12 @@ END
push(@enabledAtRuntime, $function);
}
}

if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"}) {
push(@headerContent, <<END);
static v8::Handle<v8::Value> constructorCallback(const v8::Arguments& args);
END
}

foreach my $attribute (@{$dataNode->attributes}) {
my $name = $attribute->signature->name;
@@ -1534,7 +1540,7 @@ sub GenerateImplementation
if ($hasConstructors) {
GenerateConstructorGetter($implClassName, $classIndex);
}

my $indexer;
my $namedPropertyGetter;
# Generate methods for functions.
@@ -1652,6 +1658,17 @@ END

push(@implContentDecls, "} // namespace ${interfaceName}Internal\n\n");

# In namespace WebCore, add generated implementation for 'CanBeConstructed'.
if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"}) {
push(@implContent, <<END);
v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.${interfaceName}.Contructor");
return V8Proxy::constructDOMObject<V8ClassIndex::${classIndex}, $interfaceName>(args);
}
END
}

my $access_check = "";
if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !($interfaceName eq "DOMWindow")) {
$access_check = "instance->SetAccessCheckCallbacks(V8${interfaceName}::namedSecurityCheck, V8${interfaceName}::indexedSecurityCheck, v8::Integer::New(V8ClassIndex::ToInt(V8ClassIndex::${classIndex})));";
@@ -1691,7 +1708,6 @@ static v8::Persistent<v8::FunctionTemplate> Configure${className}Template(v8::Pe
v8::Local<v8::Signature> default_signature = configureTemplate(desc, \"${interfaceName}\",
V8ClassIndex::$parentClassIndex, V8${interfaceName}::internalFieldCount,
END

# Set up our attributes if we have them
if ($has_attributes) {
push(@implContent, <<END);
@@ -1713,6 +1729,12 @@ END
END
}

if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"}) {
push(@implContent, <<END);
desc->SetCallHandler(V8${interfaceName}::constructorCallback);
END
}

if ($access_check or @enabledAtRuntime or @{$dataNode->functions} or $has_constants) {
push(@implContent, <<END);
v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
@@ -254,95 +254,6 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
// Not in the cache.
FunctionTemplateFactory factory = V8ClassIndex::GetFactory(type);
v8::Persistent<v8::FunctionTemplate> descriptor = factory();
switch (type) {
case V8ClassIndex::MESSAGECHANNEL: {
descriptor->SetCallHandler(USE_CALLBACK(MessageChannelConstructor));
break;
}

#if ENABLE(EVENTSOURCE)
case V8ClassIndex::EVENTSOURCE: {
descriptor->SetCallHandler(USE_CALLBACK(EventSourceConstructor));
break;
}
#endif

#if ENABLE(WORKERS)
case V8ClassIndex::WORKER: {
descriptor->SetCallHandler(USE_CALLBACK(WorkerConstructor));
break;
}
#endif // WORKERS

#if ENABLE(SHARED_WORKERS)
case V8ClassIndex::SHAREDWORKER: {
descriptor->SetCallHandler(USE_CALLBACK(SharedWorkerConstructor));
break;
}
#endif // SHARED_WORKERS

#if ENABLE(3D_CANVAS)
// The following objects are created from JavaScript.
case V8ClassIndex::WEBGLARRAYBUFFER:
descriptor->SetCallHandler(USE_CALLBACK(WebGLArrayBufferConstructor));
break;
case V8ClassIndex::WEBGLBYTEARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLByteArrayConstructor));
break;
case V8ClassIndex::WEBGLFLOATARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLFloatArrayConstructor));
break;
case V8ClassIndex::WEBGLINTARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLIntArrayConstructor));
break;
case V8ClassIndex::WEBGLSHORTARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLShortArrayConstructor));
break;
case V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLUnsignedByteArrayConstructor));
break;
case V8ClassIndex::WEBGLUNSIGNEDINTARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLUnsignedIntArrayConstructor));
break;
case V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY:
descriptor->SetCallHandler(USE_CALLBACK(WebGLUnsignedShortArrayConstructor));
break;
#endif
case V8ClassIndex::DOMPARSER:
descriptor->SetCallHandler(USE_CALLBACK(DOMParserConstructor));
break;
case V8ClassIndex::WEBKITCSSMATRIX:
descriptor->SetCallHandler(USE_CALLBACK(WebKitCSSMatrixConstructor));
break;
case V8ClassIndex::WEBKITPOINT:
descriptor->SetCallHandler(USE_CALLBACK(WebKitPointConstructor));
break;
#if ENABLE(WEB_SOCKETS)
case V8ClassIndex::WEBSOCKET: {
descriptor->SetCallHandler(USE_CALLBACK(WebSocketConstructor));
break;
}
#endif
case V8ClassIndex::XMLSERIALIZER:
descriptor->SetCallHandler(USE_CALLBACK(XMLSerializerConstructor));
break;
case V8ClassIndex::XMLHTTPREQUEST: {
descriptor->SetCallHandler(USE_CALLBACK(XMLHttpRequestConstructor));
break;
}
#if ENABLE(XPATH)
case V8ClassIndex::XPATHEVALUATOR:
descriptor->SetCallHandler(USE_CALLBACK(XPathEvaluatorConstructor));
break;
#endif
#if ENABLE(XSLT)
case V8ClassIndex::XSLTPROCESSOR:
descriptor->SetCallHandler(USE_CALLBACK(XSLTProcessorConstructor));
break;
#endif
default:
break;
}

*cacheCell = descriptor;
return descriptor;

0 comments on commit 4a35542

Please sign in to comment.