Refactor automatically generated JS DOM bindings to replace operator new with static create methods

https://bugs.webkit.org/show_bug.cgi?id=64732

Patch by Mark Hahnenberg <mhahnenberg@apple.com> on 2011-07-26
Reviewed by Oliver Hunt.

Source/JavaScriptCore:

Replacing the public constructors in the automatically generated JS DOM bindings with static
create methods.  JSByteArray is used by several of these bindings in WebCore.

* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::create):
* runtime/JSByteArray.h:

Source/WebCore:

No new tests.

Replacing the public constructors in the automatically generated JS DOM bindings in CodeGeneratorJS.pm
with static create methods.  This is part of a larger refactoring effort to use static create methods
in the headers of the generated files (so as to be inline-able) in favor of public constructors throughout JSC.

* bindings/js/JSAudioConstructor.h:
(WebCore::JSAudioConstructor::create):
* bindings/js/JSDOMBinding.h:
(WebCore::createWrapper):
* bindings/js/JSDOMGlobalObject.h:
(WebCore::getDOMConstructor):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::history):
(WebCore::JSDOMWindow::location):
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::setWindow):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::location):
* bindings/js/JSImageConstructor.h:
(WebCore::JSImageConstructor::create):
* bindings/js/JSImageDataCustom.cpp:
(WebCore::toJS):
* bindings/js/JSOptionConstructor.h:
(WebCore::JSOptionConstructor::create):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::initScript):
* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForTypeInImpl):
(AddIncludesForTypeInHeader):
(AddIncludesForType):
(GenerateHeader):
(GenerateImplementation):
(GenerateCallbackImplementation):
(GenerateConstructorDeclaration):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::create):
(WebCore::JSTestInterface::createPrototype):
* bindings/scripts/test/JS/JSTestInterface.h:
(WebCore::JSTestInterface::create):
(WebCore::JSTestInterfacePrototype::create):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
(WebCore::JSTestMediaQueryListListenerConstructor::create):
(WebCore::JSTestMediaQueryListListener::createPrototype):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
(WebCore::JSTestMediaQueryListListener::create):
(WebCore::JSTestMediaQueryListListenerPrototype::create):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjConstructor::create):
(WebCore::JSTestObj::createPrototype):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore::JSTestObj::create):
(WebCore::JSTestObjPrototype::create):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
(WebCore::JSTestSerializedScriptValueInterfaceConstructor::create):
(WebCore::JSTestSerializedScriptValueInterface::createPrototype):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
(WebCore::JSTestSerializedScriptValueInterface::create):
(WebCore::JSTestSerializedScriptValueInterfacePrototype::create):
* bridge/jni/jsc/JavaArrayJSC.cpp:
(JavaArray::convertJObjectToArray):
* bridge/jsc/BridgeJSC.cpp:
(JSC::Bindings::Instance::newRuntimeObject):
* bridge/objc/objc_utility.mm:
(JSC::Bindings::convertObjcValueToValue):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertQVariantToValue):
* bridge/runtime_array.h:
(JSC::RuntimeArray::create):
* bridge/runtime_object.h:
(JSC::Bindings::RuntimeObject::create):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@91790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5ef503a3
2011-07-26 Mark Hahnenberg <mhahnenberg@apple.com>
Refactor automatically generated JS DOM bindings to replace operator new with static create methods
https://bugs.webkit.org/show_bug.cgi?id=64732
Reviewed by Oliver Hunt.
Replacing the public constructors in the automatically generated JS DOM bindings with static
create methods. JSByteArray is used by several of these bindings in WebCore.
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::create):
* runtime/JSByteArray.h:
2011-07-26 Alexis Menard <alexis.menard@openbossa.org>
Unreviewed build fix for Qt/Linux.
......
......@@ -116,7 +116,7 @@ __ZN3JSC10throwErrorEPNS_9ExecStateENS_7JSValueE
__ZN3JSC10throwErrorEPNS_9ExecStateEPNS_8JSObjectE
__ZN3JSC11JSByteArray13s_defaultInfoE
__ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataENS_7JSValueEPKNS_9ClassInfoE
__ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE
__ZN3JSC11JSByteArray6createEPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE
__ZN3JSC11ParserArena5resetEv
__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE
__ZN3JSC11createErrorEPNS_9ExecStateERKNS_7UStringE
......
......@@ -10,7 +10,6 @@ EXPORTS
??0InternalFunction@JSC@@IAE@PAVJSGlobalData@1@PAVJSGlobalObject@1@PAVStructure@1@ABVIdentifier@1@@Z
??0JSArray@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@@Z
??0JSArray@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@ABVArgList@1@@Z
??0JSByteArray@JSC@@QAE@PAVExecState@1@PAVStructure@1@PAVByteArray@WTF@@@Z
??0JSFunction@JSC@@AAE@PAVExecState@1@PAVJSGlobalObject@1@PAVStructure@1@HABVIdentifier@1@P6I_J0@Z@Z
??0JSLock@JSC@@QAE@PAVExecState@1@@Z
??0JSObjectWithGlobalObject@JSC@@IAE@AAVJSGlobalData@1@PAVJSGlobalObject@1@PAVStructure@1@@Z
......@@ -96,6 +95,7 @@ EXPORTS
?convertUTF16ToUTF8@Unicode@WTF@@YA?AW4ConversionResult@12@PAPB_WPB_WPAPADPAD_N@Z
?convertUTF8ToUTF16@Unicode@WTF@@YA?AW4ConversionResult@12@PAPBDPBDPAPA_WPA_W_N@Z
?create@ByteArray@WTF@@SA?AV?$PassRefPtr@VByteArray@WTF@@@2@I@Z
?create@JSByteArray@JSC@@SAPAV12@PAVExecState@2@PAVStructure@2@PAVByteArray@WTF@@@Z
?create@JSGlobalData@JSC@@SA?AV?$PassRefPtr@VJSGlobalData@JSC@@@WTF@@W4ThreadStackType@2@@Z
?create@OpaqueJSString@@SA?AV?$PassRefPtr@UOpaqueJSString@@@WTF@@ABVUString@JSC@@@Z
?create@RegExp@JSC@@SAPAV12@AAVJSGlobalData@2@ABVUString@2@W4RegExpFlags@2@@Z
......
......@@ -41,6 +41,11 @@ JSByteArray::JSByteArray(ExecState* exec, Structure* structure, ByteArray* stora
{
putDirect(exec->globalData(), exec->globalData().propertyNames->length, jsNumber(m_storage->length()), ReadOnly | DontDelete);
}
JSByteArray* JSByteArray::create(ExecState* exec, Structure* structure, ByteArray* storage)
{
return new (allocateCell<JSByteArray>(*exec->heap())) JSByteArray(exec, structure, storage);
}
#if !ASSERT_DISABLED
JSByteArray::~JSByteArray()
......
......@@ -75,7 +75,12 @@ namespace JSC {
setIndex(i, byteValue);
}
JSByteArray(ExecState*, Structure*, WTF::ByteArray* storage);
private:
JSByteArray(ExecState*, Structure*, ByteArray* storage);
public:
static JSByteArray* create(ExecState*, Structure*, ByteArray*);
static Structure* createStructure(JSGlobalData&, JSValue prototype, const JSC::ClassInfo* = &s_defaultInfo);
virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
......
2011-07-26 Mark Hahnenberg <mhahnenberg@apple.com>
Refactor automatically generated JS DOM bindings to replace operator new with static create methods
https://bugs.webkit.org/show_bug.cgi?id=64732
Reviewed by Oliver Hunt.
No new tests.
Replacing the public constructors in the automatically generated JS DOM bindings in CodeGeneratorJS.pm
with static create methods. This is part of a larger refactoring effort to use static create methods
in the headers of the generated files (so as to be inline-able) in favor of public constructors throughout JSC.
* bindings/js/JSAudioConstructor.h:
(WebCore::JSAudioConstructor::create):
* bindings/js/JSDOMBinding.h:
(WebCore::createWrapper):
* bindings/js/JSDOMGlobalObject.h:
(WebCore::getDOMConstructor):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::history):
(WebCore::JSDOMWindow::location):
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::setWindow):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::location):
* bindings/js/JSImageConstructor.h:
(WebCore::JSImageConstructor::create):
* bindings/js/JSImageDataCustom.cpp:
(WebCore::toJS):
* bindings/js/JSOptionConstructor.h:
(WebCore::JSOptionConstructor::create):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::initScript):
* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForTypeInImpl):
(AddIncludesForTypeInHeader):
(AddIncludesForType):
(GenerateHeader):
(GenerateImplementation):
(GenerateCallbackImplementation):
(GenerateConstructorDeclaration):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::create):
(WebCore::JSTestInterface::createPrototype):
* bindings/scripts/test/JS/JSTestInterface.h:
(WebCore::JSTestInterface::create):
(WebCore::JSTestInterfacePrototype::create):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
(WebCore::JSTestMediaQueryListListenerConstructor::create):
(WebCore::JSTestMediaQueryListListener::createPrototype):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
(WebCore::JSTestMediaQueryListListener::create):
(WebCore::JSTestMediaQueryListListenerPrototype::create):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjConstructor::create):
(WebCore::JSTestObj::createPrototype):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore::JSTestObj::create):
(WebCore::JSTestObjPrototype::create):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
(WebCore::JSTestSerializedScriptValueInterfaceConstructor::create):
(WebCore::JSTestSerializedScriptValueInterface::createPrototype):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
(WebCore::JSTestSerializedScriptValueInterface::create):
(WebCore::JSTestSerializedScriptValueInterfacePrototype::create):
* bridge/jni/jsc/JavaArrayJSC.cpp:
(JavaArray::convertJObjectToArray):
* bridge/jsc/BridgeJSC.cpp:
(JSC::Bindings::Instance::newRuntimeObject):
* bridge/objc/objc_utility.mm:
(JSC::Bindings::convertObjcValueToValue):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertQVariantToValue):
* bridge/runtime_array.h:
(JSC::RuntimeArray::create):
* bridge/runtime_object.h:
(JSC::Bindings::RuntimeObject::create):
2011-07-26 Xiaomei Ji <xji@chromium.org>
--webkit-visual-word does not work in multi-line
......@@ -36,7 +36,10 @@ namespace WebCore {
class JSAudioConstructor : public DOMConstructorWithDocument {
public:
JSAudioConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
static JSAudioConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
{
return new (JSC::allocateCell<JSAudioConstructor>(*exec->heap())) JSAudioConstructor(exec, structure, globalObject);
}
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
{
......@@ -46,6 +49,7 @@ namespace WebCore {
static const JSC::ClassInfo s_info;
private:
JSAudioConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
};
......
......@@ -139,7 +139,7 @@ namespace WebCore {
{
ASSERT(node);
ASSERT(!getCachedWrapper(currentWorld(exec), node));
WrapperClass* wrapper = new (exec) WrapperClass(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, node);
WrapperClass* wrapper = WrapperClass::create(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, node);
// FIXME: The entire function can be removed, once we fix caching.
// This function is a one-off hack to make Nodes cache in the right global object.
cacheWrapper(currentWorld(exec), node, wrapper);
......
......@@ -88,7 +88,7 @@ namespace WebCore {
{
if (JSC::JSObject* constructor = const_cast<JSDOMGlobalObject*>(globalObject)->constructors().get(&ConstructorClass::s_info).get())
return constructor;
JSC::JSObject* constructor = new (exec) ConstructorClass(exec, ConstructorClass::createStructure(exec->globalData(), globalObject->objectPrototype()), const_cast<JSDOMGlobalObject*>(globalObject));
JSC::JSObject* constructor = ConstructorClass::create(exec, ConstructorClass::createStructure(exec->globalData(), globalObject->objectPrototype()), const_cast<JSDOMGlobalObject*>(globalObject));
ASSERT(!const_cast<JSDOMGlobalObject*>(globalObject)->constructors().contains(&ConstructorClass::s_info));
JSC::WriteBarrier<JSC::JSObject> temp;
const_cast<JSDOMGlobalObject*>(globalObject)->constructors().add(&ConstructorClass::s_info, temp).first->second.set(exec->globalData(), globalObject, constructor);
......
......@@ -428,7 +428,7 @@ JSValue JSDOMWindow::history(ExecState* exec) const
return wrapper;
JSDOMWindow* window = const_cast<JSDOMWindow*>(this);
JSHistory* jsHistory = new (exec) JSHistory(getDOMStructure<JSHistory>(exec, window), window, history);
JSHistory* jsHistory = JSHistory::create(getDOMStructure<JSHistory>(exec, window), window, history);
cacheWrapper(currentWorld(exec), history, jsHistory);
return jsHistory;
}
......@@ -440,7 +440,7 @@ JSValue JSDOMWindow::location(ExecState* exec) const
return wrapper;
JSDOMWindow* window = const_cast<JSDOMWindow*>(this);
JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, window), window, location);
JSLocation* jsLocation = JSLocation::create(getDOMStructure<JSLocation>(exec, window), window, location);
cacheWrapper(currentWorld(exec), location, jsLocation);
return jsLocation;
}
......
......@@ -61,10 +61,10 @@ void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
// when we allocate the global object. (Once the global object is fully
// constructed, it can mark its own prototype.)
Structure* prototypeStructure = JSDOMWindowPrototype::createStructure(*JSDOMWindow::commonJSGlobalData(), jsNull());
Strong<JSDOMWindowPrototype> prototype(*JSDOMWindow::commonJSGlobalData(), new JSDOMWindowPrototype(*JSDOMWindow::commonJSGlobalData(), 0, prototypeStructure));
Strong<JSDOMWindowPrototype> prototype(*JSDOMWindow::commonJSGlobalData(), JSDOMWindowPrototype::create(*JSDOMWindow::commonJSGlobalData(), 0, prototypeStructure));
Structure* structure = JSDOMWindow::createStructure(*JSDOMWindow::commonJSGlobalData(), prototype.get());
JSDOMWindow* jsDOMWindow = new (JSDOMWindow::commonJSGlobalData()) JSDOMWindow(*JSDOMWindow::commonJSGlobalData(), structure, domWindow, this);
JSDOMWindow* jsDOMWindow = JSDOMWindow::create(*JSDOMWindow::commonJSGlobalData(), structure, domWindow, this);
prototype->putAnonymousValue(*JSDOMWindow::commonJSGlobalData(), 0, jsDOMWindow);
setWindow(*JSDOMWindow::commonJSGlobalData(), jsDOMWindow);
}
......
......@@ -58,7 +58,7 @@ JSValue JSDocument::location(ExecState* exec) const
if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), location))
return wrapper;
JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, globalObject()), globalObject(), location);
JSLocation* jsLocation = JSLocation::create(getDOMStructure<JSLocation>(exec, globalObject()), globalObject(), location);
cacheWrapper(currentWorld(exec), location, jsLocation);
return jsLocation;
}
......
......@@ -27,7 +27,10 @@ namespace WebCore {
class JSImageConstructor : public DOMConstructorWithDocument {
public:
JSImageConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
static JSImageConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
{
return new (JSC::allocateCell<JSImageConstructor>(*exec->heap())) JSImageConstructor(exec, structure, globalObject);
}
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
{
......@@ -37,6 +40,7 @@ namespace WebCore {
static const JSC::ClassInfo s_info;
private:
JSImageConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
};
......
......@@ -49,7 +49,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageD
Identifier dataName(exec, "data");
static const ClassInfo cpaClassInfo = { "CanvasPixelArray", &JSByteArray::Base::s_info, 0, 0 };
DEFINE_STATIC_LOCAL(Strong<Structure>, cpaStructure, (exec->globalData(), JSByteArray::createStructure(exec->globalData(), jsNull(), &cpaClassInfo)));
wrapper->putDirect(exec->globalData(), dataName, new (exec) JSByteArray(exec, cpaStructure.get(), imageData->data()->data()), DontDelete | ReadOnly);
wrapper->putDirect(exec->globalData(), dataName, JSByteArray::create(exec, cpaStructure.get(), imageData->data()->data()), DontDelete | ReadOnly);
exec->heap()->reportExtraMemoryCost(imageData->data()->length());
return wrapper;
......
......@@ -28,7 +28,10 @@ namespace WebCore {
class JSOptionConstructor : public DOMConstructorWithDocument {
public:
JSOptionConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
static JSOptionConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
{
return new (JSC::allocateCell<JSOptionConstructor>(*exec->heap())) JSOptionConstructor(exec, structure, globalObject);
}
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
{
......@@ -38,6 +41,7 @@ namespace WebCore {
static const JSC::ClassInfo s_info;
private:
JSOptionConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
};
......
......@@ -75,24 +75,24 @@ void WorkerScriptController::initScript()
// when we allocate the global object. (Once the global object is fully
// constructed, it can mark its own prototype.)
Structure* workerContextPrototypeStructure = JSWorkerContextPrototype::createStructure(*m_globalData, jsNull());
Strong<JSWorkerContextPrototype> workerContextPrototype(*m_globalData, new (m_globalData.get()) JSWorkerContextPrototype(*m_globalData, 0, workerContextPrototypeStructure));
Strong<JSWorkerContextPrototype> workerContextPrototype(*m_globalData, JSWorkerContextPrototype::create(*m_globalData, 0, workerContextPrototypeStructure));
if (m_workerContext->isDedicatedWorkerContext()) {
Structure* dedicatedContextPrototypeStructure = JSDedicatedWorkerContextPrototype::createStructure(*m_globalData, workerContextPrototype.get());
Strong<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype(*m_globalData, new (m_globalData.get()) JSDedicatedWorkerContextPrototype(*m_globalData, 0, dedicatedContextPrototypeStructure));
Strong<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype(*m_globalData, JSDedicatedWorkerContextPrototype::create(*m_globalData, 0, dedicatedContextPrototypeStructure));
Structure* structure = JSDedicatedWorkerContext::createStructure(*m_globalData, dedicatedContextPrototype.get());
m_workerContextWrapper.set(*m_globalData, new (m_globalData.get()) JSDedicatedWorkerContext(*m_globalData, structure, m_workerContext->toDedicatedWorkerContext()));
m_workerContextWrapper.set(*m_globalData, JSDedicatedWorkerContext::create(*m_globalData, structure, m_workerContext->toDedicatedWorkerContext()));
workerContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get());
dedicatedContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get());
#if ENABLE(SHARED_WORKERS)
} else {
ASSERT(m_workerContext->isSharedWorkerContext());
Structure* sharedContextPrototypeStructure = JSSharedWorkerContextPrototype::createStructure(*m_globalData, workerContextPrototype.get());
Strong<JSSharedWorkerContextPrototype> sharedContextPrototype(*m_globalData, new (m_globalData.get()) JSSharedWorkerContextPrototype(*m_globalData, 0, sharedContextPrototypeStructure));
Strong<JSSharedWorkerContextPrototype> sharedContextPrototype(*m_globalData, JSSharedWorkerContextPrototype::create(*m_globalData, 0, sharedContextPrototypeStructure));
Structure* structure = JSSharedWorkerContext::createStructure(*m_globalData, sharedContextPrototype.get());
m_workerContextWrapper.set(*m_globalData, new (m_globalData.get()) JSSharedWorkerContext(*m_globalData, structure, m_workerContext->toSharedWorkerContext()));
m_workerContextWrapper.set(*m_globalData, JSSharedWorkerContext::create(*m_globalData, structure, m_workerContext->toSharedWorkerContext()));
workerContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get());
sharedContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get());
#endif
......
......@@ -235,31 +235,14 @@ sub IndexGetterReturnsStrings
return 0;
}
sub AddIncludesForType
sub AddIncludesForTypeInImpl
{
my $type = $codeGenerator->StripModule(shift);
my $isCallback = @_ ? shift : 0;
# When we're finished with the one-file-per-class
# reorganization, we won't need these special cases.
if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->AvoidInclusionOfType($type)
or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") {
} elsif ($type =~ /SVGPathSeg/) {
$joinedName = $type;
$joinedName =~ s/Abs|Rel//;
$implIncludes{"${joinedName}.h"} = 1;
} elsif ($type eq "XPathNSResolver") {
$implIncludes{"JSXPathNSResolver.h"} = 1;
$implIncludes{"JSCustomXPathNSResolver.h"} = 1;
} elsif ($isCallback) {
$implIncludes{"JS${type}.h"} = 1;
} else {
# default, include the same named file
$implIncludes{"${type}.h"} = 1;
}
AddIncludesForType($type, $isCallback, \%implIncludes);
# additional includes (things needed to compile the bindings but not the header)
if ($type eq "CanvasRenderingContext2D") {
$implIncludes{"CanvasGradient.h"} = 1;
$implIncludes{"CanvasPattern.h"} = 1;
......@@ -279,6 +262,39 @@ sub AddIncludesForType
}
}
sub AddIncludesForTypeInHeader
{
my $type = $codeGenerator->StripModule(shift);
my $isCallback = @_ ? shift : 0;
AddIncludesForType($type, $isCallback, \%headerIncludes);
}
sub AddIncludesForType
{
my $type = shift;
my $isCallback = shift;
my $includesRef = shift;
# When we're finished with the one-file-per-class
# reorganization, we won't need these special cases.
if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->AvoidInclusionOfType($type)
or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") {
} elsif ($type =~ /SVGPathSeg/) {
$joinedName = $type;
$joinedName =~ s/Abs|Rel//;
$includesRef->{"${joinedName}.h"} = 1;
} elsif ($type eq "XPathNSResolver") {
$includesRef->{"JSXPathNSResolver.h"} = 1;
$includesRef->{"JSCustomXPathNSResolver.h"} = 1;
} elsif ($isCallback) {
$includesRef->{"JS${type}.h"} = 1;
} else {
# default, include the same named file
$includesRef->{"${type}.h"} = 1;
}
}
# FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
sub AddIncludesForSVGAnimatedType
{
......@@ -672,7 +688,9 @@ sub GenerateHeader
$headerIncludes{"$implClassName.h"} = 1;
} else {
# Implementation class forward declaration
AddClassForwardIfNeeded($implClassName) unless $svgPropertyOrListPropertyType;
if ($interfaceName eq "DOMWindow" || $dataNode->extendedAttributes->{"IsWorkerContext"}) {
AddClassForwardIfNeeded($implClassName) unless $svgPropertyOrListPropertyType;
}
}
AddClassForwardIfNeeded("JSDOMWindowShell") if $interfaceName eq "DOMWindow";
......@@ -680,15 +698,25 @@ sub GenerateHeader
# Class declaration
push(@headerContent, "class $className : public $parentClassName {\n");
push(@headerContent, " typedef $parentClassName Base;\n");
push(@headerContent, "public:\n");
# Constructor
# Static create methods
push(@headerContent, "public:\n");
if ($interfaceName eq "DOMWindow") {
push(@headerContent, " $className(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<$implType>, JSDOMWindowShell*);\n");
push(@headerContent, " static $className* create(JSC::JSGlobalData& globalData, JSC::Structure* structure, PassRefPtr<$implType> impl, JSDOMWindowShell* windowShell)\n");
push(@headerContent, " {\n");
push(@headerContent, " return new (JSC::allocateCell<$className>(globalData.heap)) ${className}(globalData, structure, impl, windowShell);\n");
push(@headerContent, " }\n\n");
} elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@headerContent, " $className(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<$implType>);\n");
push(@headerContent, " static $className* create(JSC::JSGlobalData& globalData, JSC::Structure* structure, PassRefPtr<$implType> impl)\n");
push(@headerContent, " {\n");
push(@headerContent, " return new (JSC::allocateCell<$className>(globalData.heap)) ${className}(globalData, structure, impl);\n");
push(@headerContent, " }\n\n");
} else {
push(@headerContent, " $className(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<$implType>);\n");
AddIncludesForTypeInHeader($implType) unless $svgPropertyOrListPropertyType;
push(@headerContent, " static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<$implType> impl)\n");
push(@headerContent, " {\n");
push(@headerContent, " return new (JSC::allocateCell<$className>(globalObject->globalData().heap)) $className(structure, globalObject, impl);\n");
push(@headerContent, " }\n\n");
}
# Prototype
......@@ -874,8 +902,17 @@ sub GenerateHeader
push(@headerContent, " static const unsigned AnonymousSlotCount = $numCachedAttributes + Base::AnonymousSlotCount;\n");
}
# structure flags
push(@headerContent, "protected:\n");
# Constructor
if ($interfaceName eq "DOMWindow") {
push(@headerContent, " $className(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<$implType>, JSDOMWindowShell*);\n");
} elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@headerContent, " $className(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<$implType>);\n");
} else {
push(@headerContent, " $className(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<$implType>);\n");
}
# structure flags
push(@headerContent, " static const unsigned StructureFlags = ");
foreach my $structureFlag (keys %structureFlags) {
push(@headerContent, $structureFlag . " | ");
......@@ -960,13 +997,15 @@ sub GenerateHeader
push(@headerContent, "class ${className}Prototype : public JSC::JSObjectWithGlobalObject {\n");
push(@headerContent, " typedef JSC::JSObjectWithGlobalObject Base;\n");
push(@headerContent, "public:\n");
if ($interfaceName eq "DOMWindow") {
push(@headerContent, " void* operator new(size_t);\n");
} elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@headerContent, " void* operator new(size_t, JSC::JSGlobalData*);\n");
} else {
if ($interfaceName ne "DOMWindow" && !$dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n");
}
push(@headerContent, " static ${className}Prototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)\n");
push(@headerContent, " {\n");
push(@headerContent, " return new (JSC::allocateCell<${className}Prototype>(globalData.heap)) ${className}Prototype(globalData, globalObject, structure);\n");
push(@headerContent, " }\n\n");
push(@headerContent, " static const JSC::ClassInfo s_info;\n");
if ($numFunctions > 0 || $numConstants > 0 || $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}) {
push(@headerContent, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n");
......@@ -991,6 +1030,7 @@ sub GenerateHeader
# Custom defineGetter function
push(@headerContent, " virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomPrototypeDefineGetter"};
push(@headerContent, "\nprivate:\n");
push(@headerContent, " ${className}Prototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) : JSC::JSObjectWithGlobalObject(globalData, globalObject, structure) { }\n");
# structure flags
......@@ -1256,7 +1296,7 @@ sub GenerateImplementation
$implIncludes{"<wtf/GetPtr.h>"} = 1;
$implIncludes{"<runtime/PropertyNameArray.h>"} = 1 if $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"};
AddIncludesForType($interfaceName);
AddIncludesForTypeInImpl($interfaceName);
@implContent = ();
......@@ -1351,17 +1391,7 @@ sub GenerateImplementation
} else {
push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", &JSC::JSObjectWithGlobalObject::s_info, &${className}PrototypeTable, 0 };\n\n");
}
if ($interfaceName eq "DOMWindow") {
push(@implContent, "void* ${className}Prototype::operator new(size_t size)\n");
push(@implContent, "{\n");
push(@implContent, " return JSDOMWindow::commonJSGlobalData()->heap.allocate(size);\n");
push(@implContent, "}\n\n");
} elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@implContent, "void* ${className}Prototype::operator new(size_t size, JSGlobalData* globalData)\n");
push(@implContent, "{\n");
push(@implContent, " return globalData->heap.allocate(size);\n");
push(@implContent, "}\n\n");
} else {
if ($interfaceName ne "DOMWindow" && !$dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec, JSGlobalObject* globalObject)\n");
push(@implContent, "{\n");
push(@implContent, " return getDOMPrototype<${className}>(exec, globalObject);\n");
......@@ -1448,11 +1478,11 @@ sub GenerateImplementation
# Constructor
if ($interfaceName eq "DOMWindow") {
AddIncludesForType("JSDOMWindowShell");
AddIncludesForTypeInImpl("JSDOMWindowShell");
push(@implContent, "${className}::$className(JSGlobalData& globalData, Structure* structure, PassRefPtr<$implType> impl, JSDOMWindowShell* shell)\n");
push(@implContent, " : $parentClassName(globalData, structure, impl, shell)\n");
} elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
AddIncludesForType($interfaceName);
AddIncludesForTypeInImpl($interfaceName);
push(@implContent, "${className}::$className(JSGlobalData& globalData, Structure* structure, PassRefPtr<$implType> impl)\n");
push(@implContent, " : $parentClassName(globalData, structure, impl)\n");
} else {
......@@ -1487,9 +1517,9 @@ sub GenerateImplementation
push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec, JSGlobalObject* globalObject)\n");
push(@implContent, "{\n");
if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") {
push(@implContent, " return new (exec) ${className}Prototype(exec->globalData(), globalObject, ${className}Prototype::createStructure(exec->globalData(), ${parentClassName}Prototype::self(exec, globalObject)));\n");
push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(exec->globalData(), ${parentClassName}Prototype::self(exec, globalObject)));\n");
} else {
push(@implContent, " return new (exec) ${className}Prototype(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));\n");
push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));\n");
}
push(@implContent, "}\n\n");
}
......@@ -1890,7 +1920,7 @@ sub GenerateImplementation
# Functions
if ($numFunctions > 0) {
foreach my $function (@{$dataNode->functions}) {
AddIncludesForType($function->signature->type);
AddIncludesForTypeInImpl($function->signature->type);
my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name);
......@@ -2411,12 +2441,12 @@ sub GenerateCallbackImplementation
next;
}
AddIncludesForType($function->signature->type);
AddIncludesForTypeInImpl($function->signature->type);
push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(");
my @args = ();
foreach my $param (@params) {
AddIncludesForType($param->type, 1);
AddIncludesForTypeInImpl($param->type, 1);
push(@args, GetNativeType($param->type) . " " . $param->name);
}
push(@implContent, join(", ", @args));
......@@ -3033,8 +3063,14 @@ sub GenerateConstructorDeclaration
my $callWith = $dataNode->extendedAttributes->{"CallWith"};
push(@$outputArray, "class ${constructorClassName} : public DOMConstructorObject {\n");
push(@$outputArray, "public:\n");
push(@$outputArray, "private:\n");
push(@$outputArray, " ${constructorClassName}(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);\n\n");
push(@$outputArray, "public:\n");
push(@$outputArray, " static $constructorClassName* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)\n");
push(@$outputArray, " {\n");
push(@$outputArray, " return new (JSC::allocateCell<$constructorClassName>(*exec->heap())) $constructorClassName(exec, structure, globalObject);\n");
push(@$outputArray, " }\n\n");
push(@$outputArray, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n");
push(@$outputArray, " virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n");
......
......@@ -63,9 +63,15 @@ static const HashTableValue JSTestInterfaceConstructorTableValues[] =
#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSTestInterfaceConstructorTable = { 1, 0, JSTestInterfaceConstructorTableValues, 0 };
class JSTestInterfaceConstructor : public DOMConstructorObject {
public:
private:
JSTestInterfaceConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
public:
static JSTestInterfaceConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
{
return new (JSC::allocateCell<JSTestInterfaceConstructor>(*exec->heap())) JSTestInterfaceConstructor(exec, structure, globalObject);
}
virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
static const JSC::ClassInfo s_info;
......@@ -144,7 +150,7 @@ JSTestInterface::JSTestInterface