Refactor automatically generated JS DOM bindings to replace operator new with static...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jul 2011 21:56:13 +0000 (21:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jul 2011 21:56:13 +0000 (21:56 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@91790 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.exp
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/runtime/JSByteArray.cpp
Source/JavaScriptCore/runtime/JSByteArray.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSAudioConstructor.h
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMGlobalObject.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSDOMWindowShell.cpp
Source/WebCore/bindings/js/JSDocumentCustom.cpp
Source/WebCore/bindings/js/JSImageConstructor.h
Source/WebCore/bindings/js/JSImageDataCustom.cpp
Source/WebCore/bindings/js/JSOptionConstructor.h
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h
Source/WebCore/bridge/jni/jsc/JavaArrayJSC.cpp
Source/WebCore/bridge/jsc/BridgeJSC.cpp
Source/WebCore/bridge/objc/objc_utility.mm
Source/WebCore/bridge/qt/qt_runtime.cpp
Source/WebCore/bridge/runtime_array.h
Source/WebCore/bridge/runtime_object.h

index 2e58bd8..fc20480 100644 (file)
@@ -1,3 +1,19 @@
+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.
index 4a7a3db..43318ce 100644 (file)
@@ -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
index 6586cef..4428db6 100644 (file)
@@ -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
index c2abaee..d924a7a 100644 (file)
@@ -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()
index c481bb4..8691569 100644 (file)
@@ -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&);
index b19db49..d0b5be9 100644 (file)
@@ -1,3 +1,82 @@
+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
index 4dd3307..ce24a23 100644 (file)
@@ -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&);
     };
 
index 59cbb0c..1cd2d7c 100644 (file)
@@ -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);
index 564fea4..861df1f 100644 (file)
@@ -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);
index 868c6cc..7448176 100644 (file)
@@ -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;
 }
index bf98583..180bb21 100644 (file)
@@ -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);
 }
index 0aa47dd..5faa340 100644 (file)
@@ -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;
 }
index 0cd4233..10206c3 100644 (file)
@@ -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&);
     };
 
index 420b60c..ddbef53 100644 (file)
@@ -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;
index 691b6b4..0b48eed 100644 (file)
@@ -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&);
     };
 
index 1f29dfc..327cdb6 100644 (file)
@@ -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
index 66495d8..3f9dc6c 100644 (file)
@@ -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");
index 5812754..14f0973 100644 (file)
@@ -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(Structure* structure, JSDOMGlobalObject* global
 
 JSObject* JSTestInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
 {
-    return new (exec) JSTestInterfacePrototype(exec->globalData(), globalObject, JSTestInterfacePrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
+    return JSTestInterfacePrototype::create(exec->globalData(), globalObject, JSTestInterfacePrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
 }
 
 bool JSTestInterface::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index a90f413..02fb2fc 100644 (file)
 #if ENABLE(Condition1) || ENABLE(Condition2)
 
 #include "JSDOMBinding.h"
+#include "TestInterface.h"
 #include <runtime/JSGlobalObject.h>
 #include <runtime/JSObjectWithGlobalObject.h>
 #include <runtime/ObjectPrototype.h>
 
 namespace WebCore {
 
-class TestInterface;
-
 class JSTestInterface : public JSDOMWrapper {
     typedef JSDOMWrapper Base;
 public:
-    JSTestInterface(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestInterface>);
+    static JSTestInterface* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestInterface> impl)
+    {
+        return new (JSC::allocateCell<JSTestInterface>(globalObject->globalData().heap)) JSTestInterface(structure, globalObject, impl);
+    }
+
     static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
@@ -52,6 +55,7 @@ public:
 private:
     RefPtr<TestInterface> m_impl;
 protected:
+    JSTestInterface(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestInterface>);
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
 };
 
@@ -62,11 +66,18 @@ class JSTestInterfacePrototype : public JSC::JSObjectWithGlobalObject {
     typedef JSC::JSObjectWithGlobalObject Base;
 public:
     static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);
+    static JSTestInterfacePrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        return new (JSC::allocateCell<JSTestInterfacePrototype>(globalData.heap)) JSTestInterfacePrototype(globalData, globalObject, structure);
+    }
+
     static const JSC::ClassInfo s_info;
     static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
     {
         return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
     }
+
+private:
     JSTestInterfacePrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) : JSC::JSObjectWithGlobalObject(globalData, globalObject, structure) { }
 protected:
     static const unsigned StructureFlags = Base::StructureFlags;
index fb5cc6c..3f058d6 100644 (file)
@@ -64,9 +64,15 @@ static const HashTableValue JSTestMediaQueryListListenerConstructorTableValues[]
 #undef THUNK_GENERATOR
 static JSC_CONST_HASHTABLE HashTable JSTestMediaQueryListListenerConstructorTable = { 1, 0, JSTestMediaQueryListListenerConstructorTableValues, 0 };
 class JSTestMediaQueryListListenerConstructor : public DOMConstructorObject {
-public:
+private:
     JSTestMediaQueryListListenerConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
 
+public:
+    static JSTestMediaQueryListListenerConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+    {
+        return new (JSC::allocateCell<JSTestMediaQueryListListenerConstructor>(*exec->heap())) JSTestMediaQueryListListenerConstructor(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;
@@ -140,7 +146,7 @@ JSTestMediaQueryListListener::JSTestMediaQueryListListener(Structure* structure,
 
 JSObject* JSTestMediaQueryListListener::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
 {
-    return new (exec) JSTestMediaQueryListListenerPrototype(exec->globalData(), globalObject, JSTestMediaQueryListListenerPrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
+    return JSTestMediaQueryListListenerPrototype::create(exec->globalData(), globalObject, JSTestMediaQueryListListenerPrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
 }
 
 bool JSTestMediaQueryListListener::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index e92af17..1373a08 100644 (file)
 #define JSTestMediaQueryListListener_h
 
 #include "JSDOMBinding.h"
+#include "TestMediaQueryListListener.h"
 #include <runtime/JSGlobalObject.h>
 #include <runtime/JSObjectWithGlobalObject.h>
 #include <runtime/ObjectPrototype.h>
 
 namespace WebCore {
 
-class TestMediaQueryListListener;
-
 class JSTestMediaQueryListListener : public JSDOMWrapper {
     typedef JSDOMWrapper Base;
 public:
-    JSTestMediaQueryListListener(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestMediaQueryListListener>);
+    static JSTestMediaQueryListListener* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestMediaQueryListListener> impl)
+    {
+        return new (JSC::allocateCell<JSTestMediaQueryListListener>(globalObject->globalData().heap)) JSTestMediaQueryListListener(structure, globalObject, impl);
+    }
+
     static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
@@ -50,6 +53,7 @@ public:
 private:
     RefPtr<TestMediaQueryListListener> m_impl;
 protected:
+    JSTestMediaQueryListListener(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestMediaQueryListListener>);
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
 };
 
@@ -60,6 +64,11 @@ class JSTestMediaQueryListListenerPrototype : public JSC::JSObjectWithGlobalObje
     typedef JSC::JSObjectWithGlobalObject Base;
 public:
     static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);
+    static JSTestMediaQueryListListenerPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        return new (JSC::allocateCell<JSTestMediaQueryListListenerPrototype>(globalData.heap)) JSTestMediaQueryListListenerPrototype(globalData, globalObject, structure);
+    }
+
     static const JSC::ClassInfo s_info;
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
@@ -67,6 +76,8 @@ public:
     {
         return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
     }
+
+private:
     JSTestMediaQueryListListenerPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) : JSC::JSObjectWithGlobalObject(globalData, globalObject, structure) { }
 protected:
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
index da0092c..4246f8f 100644 (file)
@@ -143,9 +143,15 @@ COMPILE_ASSERT(0X20 == TestObj::CONST_VALUE_13, TestObjEnumCONST_VALUE_13IsWrong
 COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDontCheckEnums);
 
 class JSTestObjConstructor : public DOMConstructorObject {
-public:
+private:
     JSTestObjConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
 
+public:
+    static JSTestObjConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+    {
+        return new (JSC::allocateCell<JSTestObjConstructor>(*exec->heap())) JSTestObjConstructor(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;
@@ -265,7 +271,7 @@ JSTestObj::JSTestObj(Structure* structure, JSDOMGlobalObject* globalObject, Pass
 
 JSObject* JSTestObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
 {
-    return new (exec) JSTestObjPrototype(exec->globalData(), globalObject, JSTestObjPrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
+    return JSTestObjPrototype::create(exec->globalData(), globalObject, JSTestObjPrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
 }
 
 bool JSTestObj::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index 950029f..89292e2 100644 (file)
 #define JSTestObj_h
 
 #include "JSDOMBinding.h"
+#include "TestObj.h"
 #include <runtime/JSGlobalObject.h>
 #include <runtime/JSObjectWithGlobalObject.h>
 #include <runtime/ObjectPrototype.h>
 
 namespace WebCore {
 
-class TestObj;
-
 class JSTestObj : public JSDOMWrapper {
     typedef JSDOMWrapper Base;
 public:
-    JSTestObj(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestObj>);
+    static JSTestObj* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl)
+    {
+        return new (JSC::allocateCell<JSTestObj>(globalObject->globalData().heap)) JSTestObj(structure, globalObject, impl);
+    }
+
     static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
@@ -59,6 +62,7 @@ public:
 private:
     RefPtr<TestObj> m_impl;
 protected:
+    JSTestObj(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestObj>);
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
 };
 
@@ -69,6 +73,11 @@ class JSTestObjPrototype : public JSC::JSObjectWithGlobalObject {
     typedef JSC::JSObjectWithGlobalObject Base;
 public:
     static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);
+    static JSTestObjPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        return new (JSC::allocateCell<JSTestObjPrototype>(globalData.heap)) JSTestObjPrototype(globalData, globalObject, structure);
+    }
+
     static const JSC::ClassInfo s_info;
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
@@ -76,6 +85,8 @@ public:
     {
         return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
     }
+
+private:
     JSTestObjPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) : JSC::JSObjectWithGlobalObject(globalData, globalObject, structure) { }
 protected:
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
index 75f4d33..1363515 100644 (file)
@@ -65,9 +65,15 @@ static const HashTableValue JSTestSerializedScriptValueInterfaceConstructorTable
 #undef THUNK_GENERATOR
 static JSC_CONST_HASHTABLE HashTable JSTestSerializedScriptValueInterfaceConstructorTable = { 1, 0, JSTestSerializedScriptValueInterfaceConstructorTableValues, 0 };
 class JSTestSerializedScriptValueInterfaceConstructor : public DOMConstructorObject {
-public:
+private:
     JSTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);
 
+public:
+    static JSTestSerializedScriptValueInterfaceConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+    {
+        return new (JSC::allocateCell<JSTestSerializedScriptValueInterfaceConstructor>(*exec->heap())) JSTestSerializedScriptValueInterfaceConstructor(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;
@@ -130,7 +136,7 @@ JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Struc
 
 JSObject* JSTestSerializedScriptValueInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
 {
-    return new (exec) JSTestSerializedScriptValueInterfacePrototype(exec->globalData(), globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
+    return JSTestSerializedScriptValueInterfacePrototype::create(exec->globalData(), globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
 }
 
 bool JSTestSerializedScriptValueInterface::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index 13169af..32d98a6 100644 (file)
 #if ENABLE(Condition1) || ENABLE(Condition2)
 
 #include "JSDOMBinding.h"
+#include "TestSerializedScriptValueInterface.h"
 #include <runtime/JSGlobalObject.h>
 #include <runtime/JSObjectWithGlobalObject.h>
 #include <runtime/ObjectPrototype.h>
 
 namespace WebCore {
 
-class TestSerializedScriptValueInterface;
-
 class JSTestSerializedScriptValueInterface : public JSDOMWrapper {
     typedef JSDOMWrapper Base;
 public:
-    JSTestSerializedScriptValueInterface(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestSerializedScriptValueInterface>);
+    static JSTestSerializedScriptValueInterface* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl)
+    {
+        return new (JSC::allocateCell<JSTestSerializedScriptValueInterface>(globalObject->globalData().heap)) JSTestSerializedScriptValueInterface(structure, globalObject, impl);
+    }
+
     static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
@@ -52,6 +55,7 @@ public:
 private:
     RefPtr<TestSerializedScriptValueInterface> m_impl;
 protected:
+    JSTestSerializedScriptValueInterface(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestSerializedScriptValueInterface>);
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
 };
 
@@ -62,11 +66,18 @@ class JSTestSerializedScriptValueInterfacePrototype : public JSC::JSObjectWithGl
     typedef JSC::JSObjectWithGlobalObject Base;
 public:
     static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);
+    static JSTestSerializedScriptValueInterfacePrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        return new (JSC::allocateCell<JSTestSerializedScriptValueInterfacePrototype>(globalData.heap)) JSTestSerializedScriptValueInterfacePrototype(globalData, globalObject, structure);
+    }
+
     static const JSC::ClassInfo s_info;
     static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
     {
         return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
     }
+
+private:
     JSTestSerializedScriptValueInterfacePrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) : JSC::JSObjectWithGlobalObject(globalData, globalObject, structure) { }
 protected:
     static const unsigned StructureFlags = Base::StructureFlags;
index b08514d..66f4ec8 100644 (file)
@@ -47,7 +47,7 @@ JSValue JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, cons
     if (type[0] != '[')
         return jsUndefined();
 
-    return new (exec) RuntimeArray(exec, new JavaArray(anObject, type, rootObject));
+    return RuntimeArray::create(exec, new JavaArray(anObject, type, rootObject));
 }
 
 JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject)
index 9c0adfc..1d67041 100644 (file)
@@ -106,7 +106,7 @@ RuntimeObject* Instance::newRuntimeObject(ExecState* exec)
 
     // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
     // We need to pass in the right global object for "i".
-    return new (exec) RuntimeObject(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeObject>(exec), this);
+    return RuntimeObject::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeObject>(exec), this);
 }
 
 void Instance::willInvalidateRuntimeObject()
index dfba852..1a7b929 100644 (file)
@@ -244,7 +244,7 @@ JSValue convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType typ
             if ([obj isKindOfClass:[NSNumber class]])
                 return jsNumber([obj doubleValue]);
             if ([obj isKindOfClass:[NSArray class]])
-                return new (exec) RuntimeArray(exec, new ObjcArray(obj, rootObject));
+                return RuntimeArray::create(exec, new ObjcArray(obj, rootObject));
             if ([obj isKindOfClass:webScriptObjectClass()]) {
                 JSObject* imp = [obj _imp];
                 return imp ? imp : jsUndefined();
index b34f4cf..5683056 100644 (file)
@@ -915,7 +915,7 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
         QByteArray qtByteArray = variant.value<QByteArray>();
         WTF::RefPtr<WTF::ByteArray> wtfByteArray = WTF::ByteArray::create(qtByteArray.length());
         memcpy(wtfByteArray->data(), qtByteArray.constData(), qtByteArray.length());
-        return new (exec) JSC::JSByteArray(exec, JSC::JSByteArray::createStructure(exec->globalData(), jsNull()), wtfByteArray.get());
+        return JSC::JSByteArray::create(exec, JSC::JSByteArray::createStructure(exec->globalData(), jsNull()), wtfByteArray.get());
     }
 
     if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
@@ -973,16 +973,16 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
     if (type == QMetaType::QVariantList) {
         QVariantList vl = variant.toList();
         qConvDebug() << "got a " << vl.count() << " length list:" << vl;
-        return new (exec) RuntimeArray(exec, new QtArray<QVariant>(vl, QMetaType::Void, root));
+        return RuntimeArray::create(exec, new QtArray<QVariant>(vl, QMetaType::Void, root));
     } else if (type == QMetaType::QStringList) {
         QStringList sl = variant.value<QStringList>();
-        return new (exec) RuntimeArray(exec, new QtArray<QString>(sl, QMetaType::QString, root));
+        return RuntimeArray::create(exec, new QtArray<QString>(sl, QMetaType::QString, root));
     } else if (type == (QMetaType::Type) qMetaTypeId<QObjectList>()) {
         QObjectList ol= variant.value<QObjectList>();
-        return new (exec) RuntimeArray(exec, new QtArray<QObject*>(ol, QMetaType::QObjectStar, root));
+        return RuntimeArray::create(exec, new QtArray<QObject*>(ol, QMetaType::QObjectStar, root));
     } else if (type == (QMetaType::Type)qMetaTypeId<QList<int> >()) {
         QList<int> il= variant.value<QList<int> >();
-        return new (exec) RuntimeArray(exec, new QtArray<int>(il, QMetaType::Int, root));
+        return RuntimeArray::create(exec, new QtArray<int>(il, QMetaType::Int, root));
     }
 
     if (type == (QMetaType::Type)qMetaTypeId<QVariant>()) {
index 8fd3052..668a156 100644 (file)
@@ -33,8 +33,12 @@ namespace JSC {
     
 class RuntimeArray : public JSArray {
 public:
+    static RuntimeArray* create(ExecState* exec, Bindings::Array* array)
+    {
+        return new (allocateCell<RuntimeArray>(*exec->heap())) RuntimeArray(exec, array);
+    }
+
     typedef Bindings::Array BindingsArray;
-    RuntimeArray(ExecState*, Bindings::Array*);
     virtual ~RuntimeArray();
 
     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
@@ -67,6 +71,7 @@ protected:
     static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSArray::StructureFlags;
 
 private:
+    RuntimeArray(ExecState*, Bindings::Array*);
     static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
     static JSValue indexGetter(ExecState*, JSValue, unsigned);
 };
index 8998102..e82f82f 100644 (file)
@@ -35,7 +35,11 @@ namespace Bindings {
 
 class RuntimeObject : public JSObjectWithGlobalObject {
 public:
-    RuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<Instance>);
+    static RuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, PassRefPtr<Instance> instance)
+    {
+        return new (allocateCell<RuntimeObject>(*exec->heap())) RuntimeObject(exec, globalObject, structure, instance);
+    }
+
     virtual ~RuntimeObject();
 
     virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
@@ -67,6 +71,7 @@ public:
     }
 
 protected:
+    RuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<Instance>);
     static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObjectWithGlobalObject::StructureFlags;
 
 private: