- Revision
- 97839
- Author
- [email protected]
- Date
- 2011-10-19 00:47:20 -0700 (Wed, 19 Oct 2011)
Log Message
Rename AllowAllocation to ConstructorMode
https://bugs.webkit.org/show_bug.cgi?id=70397
Reviewed by Adam Barth.
The name 'AllowAllocation' is confusing (See discussion here: bug 70015).
This patch renames 'AllowAllocation' to 'ConstructorMode' to clarify that
this class is for distinguishing the following two situations:
1. A programmer allocates an object via "new X"; X is a function with a C++ constructCallback.
2. C++ allocates an object via the function template and tries to wrap the object with a JS flavor.
Tests: fast/events/constructors/*
* bindings/scripts/CodeGeneratorV8.pm: Renamed AllowAllocation to ConstructorMode.
(GenerateConstructorCallback):
* bindings/scripts/test/V8/V8TestInterface.cpp: Updated a run-binding-tests result.
(WebCore::V8TestInterface::constructorCallback):
* bindings/v8/V8Binding.cpp: Renamed AllowAllocation to ConstructorMode.
(WebCore::V8BindingPerIsolateData::V8BindingPerIsolateData):
* bindings/v8/V8Binding.h: Ditto.
(WebCore::ConstructorMode::ConstructorMode):
(WebCore::ConstructorMode::~ConstructorMode):
(WebCore::ConstructorMode::current):
(WebCore::SafeAllocation::newInstance):
* bindings/v8/V8Proxy.cpp: Ditto.
(WebCore::V8Proxy::checkNewLegal):
* bindings/v8/custom/V8EventConstructors.cpp: Ditto.
(WebCore::constructV8Event):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (97838 => 97839)
--- trunk/Source/WebCore/ChangeLog 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/ChangeLog 2011-10-19 07:47:20 UTC (rev 97839)
@@ -1,3 +1,34 @@
+2011-10-19 Kentaro Hara <[email protected]>
+
+ Rename AllowAllocation to ConstructorMode
+ https://bugs.webkit.org/show_bug.cgi?id=70397
+
+ Reviewed by Adam Barth.
+
+ The name 'AllowAllocation' is confusing (See discussion here: bug 70015).
+ This patch renames 'AllowAllocation' to 'ConstructorMode' to clarify that
+ this class is for distinguishing the following two situations:
+ 1. A programmer allocates an object via "new X"; X is a function with a C++ constructCallback.
+ 2. C++ allocates an object via the function template and tries to wrap the object with a JS flavor.
+
+ Tests: fast/events/constructors/*
+
+ * bindings/scripts/CodeGeneratorV8.pm: Renamed AllowAllocation to ConstructorMode.
+ (GenerateConstructorCallback):
+ * bindings/scripts/test/V8/V8TestInterface.cpp: Updated a run-binding-tests result.
+ (WebCore::V8TestInterface::constructorCallback):
+ * bindings/v8/V8Binding.cpp: Renamed AllowAllocation to ConstructorMode.
+ (WebCore::V8BindingPerIsolateData::V8BindingPerIsolateData):
+ * bindings/v8/V8Binding.h: Ditto.
+ (WebCore::ConstructorMode::ConstructorMode):
+ (WebCore::ConstructorMode::~ConstructorMode):
+ (WebCore::ConstructorMode::current):
+ (WebCore::SafeAllocation::newInstance):
+ * bindings/v8/V8Proxy.cpp: Ditto.
+ (WebCore::V8Proxy::checkNewLegal):
+ * bindings/v8/custom/V8EventConstructors.cpp: Ditto.
+ (WebCore::constructV8Event):
+
2011-10-19 Tomasz Morawski <[email protected]>
[EFL] Added missing dummy platformDescription function
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (97838 => 97839)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-10-19 07:47:20 UTC (rev 97839)
@@ -1532,7 +1532,7 @@
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
- if (AllowAllocation::current())
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
END
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (97838 => 97839)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2011-10-19 07:47:20 UTC (rev 97839)
@@ -50,7 +50,7 @@
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
- if (AllowAllocation::current())
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
if (args.Length() < 1)
return throwError("Not enough arguments", V8Proxy::TypeError);
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (97838 => 97839)
--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2011-10-19 07:47:20 UTC (rev 97839)
@@ -51,7 +51,7 @@
V8BindingPerIsolateData::V8BindingPerIsolateData(v8::Isolate* isolate)
: m_domDataStore(0)
- , m_currentAllocationsAllowed(false)
+ , m_constructorMode(ConstructorMode::CreateNewObject)
{
}
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (97838 => 97839)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2011-10-19 07:47:20 UTC (rev 97839)
@@ -87,7 +87,7 @@
RefPtr<StringImpl> m_lastStringImpl;
};
- class AllowAllocation;
+ class ConstructorMode;
#ifndef NDEBUG
typedef HashMap<v8::Value*, GlobalHandleInfo*> GlobalHandleMap;
@@ -163,30 +163,35 @@
V8HiddenPropertyName m_hiddenPropertyName;
- bool m_currentAllocationsAllowed;
- friend class AllowAllocation;
+ bool m_constructorMode;
+ friend class ConstructorMode;
#ifndef NDEBUG
GlobalHandleMap m_globalHandleMap;
#endif
};
- class AllowAllocation {
+ class ConstructorMode {
public:
- AllowAllocation()
+ enum Mode {
+ WrapExistingObject,
+ CreateNewObject
+ };
+
+ ConstructorMode()
{
V8BindingPerIsolateData* data = ""
- m_previous = data->m_currentAllocationsAllowed;
- data->m_currentAllocationsAllowed = true;
+ m_previous = data->m_constructorMode;
+ data->m_constructorMode = WrapExistingObject;
}
- ~AllowAllocation()
+ ~ConstructorMode()
{
V8BindingPerIsolateData* data = ""
- data->m_currentAllocationsAllowed = m_previous;
+ data->m_constructorMode = m_previous;
}
- static bool current() { return V8BindingPerIsolateData::current()->m_currentAllocationsAllowed; }
+ static bool current() { return V8BindingPerIsolateData::current()->m_constructorMode; }
private:
bool m_previous;
@@ -203,7 +208,7 @@
{
if (function.IsEmpty())
return v8::Local<v8::Object>();
- AllowAllocation allow;
+ ConstructorMode constructorMode;
return function->NewInstance();
}
@@ -211,7 +216,7 @@
{
if (objectTemplate.IsEmpty())
return v8::Local<v8::Object>();
- AllowAllocation allow;
+ ConstructorMode constructorMode;
return objectTemplate->NewInstance();
}
@@ -219,7 +224,7 @@
{
if (function.IsEmpty())
return v8::Local<v8::Object>();
- AllowAllocation allow;
+ ConstructorMode constructorMode;
return function->NewInstance(argc, argv);
}
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (97838 => 97839)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2011-10-19 07:47:20 UTC (rev 97839)
@@ -782,7 +782,7 @@
v8::Handle<v8::Value> V8Proxy::checkNewLegal(const v8::Arguments& args)
{
- if (!AllowAllocation::current())
+ if (ConstructorMode::current() == ConstructorMode::CreateNewObject)
return throwError(TypeError, "Illegal constructor");
return args.This();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp (97838 => 97839)
--- trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp 2011-10-19 07:32:14 UTC (rev 97838)
+++ trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp 2011-10-19 07:47:20 UTC (rev 97839)
@@ -77,7 +77,7 @@
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
- if (AllowAllocation::current())
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
if (args.Length() < 1)