Title: [135359] trunk/Source/WebCore
Revision
135359
Author
hara...@chromium.org
Date
2012-11-21 01:08:02 -0800 (Wed, 21 Nov 2012)

Log Message

[V8] Replace V8Parameter::prepare() with V8Parameter::operator=()
https://bugs.webkit.org/show_bug.cgi?id=102870

Reviewed by Adam Barth.

This is an incremental step for V8Parameter refactoring.
By replacing V8Parameter::prepare() with V8Parameter::operator=(),
we can make EXCEPTION_BLOCK() and STRING_TO_V8PARAMETER_EXCEPTION_BLOCK()
equivalent (except for a return value).

Tests: fast/workers/worker-constructor.html
       storage/websql/sql-error-codes.html
       inspector/console/alert-toString-exception.html
       http/tests/websocket/tests/hybi/send-throw.html

* bindings/v8/V8BindingMacros.h:
* bindings/v8/V8StringResource.h:
(WebCore::V8Parameter::V8Parameter):
(V8Parameter):
(WebCore::=):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135358 => 135359)


--- trunk/Source/WebCore/ChangeLog	2012-11-21 09:06:58 UTC (rev 135358)
+++ trunk/Source/WebCore/ChangeLog	2012-11-21 09:08:02 UTC (rev 135359)
@@ -1,5 +1,28 @@
 2012-11-21  Kentaro Hara  <hara...@chromium.org>
 
+        [V8] Replace V8Parameter::prepare() with V8Parameter::operator=()
+        https://bugs.webkit.org/show_bug.cgi?id=102870
+
+        Reviewed by Adam Barth.
+
+        This is an incremental step for V8Parameter refactoring.
+        By replacing V8Parameter::prepare() with V8Parameter::operator=(),
+        we can make EXCEPTION_BLOCK() and STRING_TO_V8PARAMETER_EXCEPTION_BLOCK()
+        equivalent (except for a return value).
+
+        Tests: fast/workers/worker-constructor.html
+               storage/websql/sql-error-codes.html
+               inspector/console/alert-toString-exception.html
+               http/tests/websocket/tests/hybi/send-throw.html
+
+        * bindings/v8/V8BindingMacros.h:
+        * bindings/v8/V8StringResource.h:
+        (WebCore::V8Parameter::V8Parameter):
+        (V8Parameter):
+        (WebCore::=):
+
+2012-11-21  Kentaro Hara  <hara...@chromium.org>
+
         [V8] Rename v8/custom/*Constructor.cpp to v8/custom/*Custom.cpp
         https://bugs.webkit.org/show_bug.cgi?id=102881
 

Modified: trunk/Source/WebCore/bindings/v8/V8BindingMacros.h (135358 => 135359)


--- trunk/Source/WebCore/bindings/v8/V8BindingMacros.h	2012-11-21 09:06:58 UTC (rev 135358)
+++ trunk/Source/WebCore/bindings/v8/V8BindingMacros.h	2012-11-21 09:08:02 UTC (rev 135359)
@@ -54,10 +54,10 @@
     }
 
 #define STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(type, var, value) \
-    type var(value);                                            \
+    type var;                                                   \
     {                                                           \
         v8::TryCatch block;                                     \
-        var.prepare();                                          \
+        var = (value);                                          \
         if (block.HasCaught()) {                                \
             block.ReThrow();                                    \
             return v8::Undefined();                             \
@@ -65,10 +65,10 @@
     }
 
 #define STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(type, var, value) \
-    type var(value);                                                 \
+    type var;                                                        \
     {                                                                \
         v8::TryCatch block;                                          \
-        var.prepare();                                               \
+        var = (value);                                               \
         if (block.HasCaught()) {                                     \
             block.ReThrow();                                         \
             return;                                                  \

Modified: trunk/Source/WebCore/bindings/v8/V8StringResource.h (135358 => 135359)


--- trunk/Source/WebCore/bindings/v8/V8StringResource.h	2012-11-21 09:06:58 UTC (rev 135358)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.h	2012-11-21 09:08:02 UTC (rev 135359)
@@ -52,16 +52,15 @@
 template <V8ParameterMode Mode = DefaultMode>
 class V8Parameter {
 public:
-    V8Parameter(v8::Local<v8::Value> object)
-        : m_v8Object(object)
-        , m_mode(Externalize)
+    V8Parameter()
+        : m_mode(Externalize)
         , m_string()
     {
     }
 
     // This can throw. You must use this through the
     // STRING_TO_V8PARAMETER_EXCEPTION_BLOCK() macro.
-    void prepare();
+    V8Parameter& operator=(v8::Local<v8::Value>);
     operator String() { return toString<String>(); }
     operator AtomicString() { return toString<AtomicString>(); }
 
@@ -83,8 +82,6 @@
         m_v8Object = m_v8Object->ToString();
     }
 
-    v8::Local<v8::Value> object() { return m_v8Object; }
-
     void setString(const String& string)
     {
         m_string = string;
@@ -105,27 +102,31 @@
     String m_string;
 };
 
-template<> inline void V8Parameter<DefaultMode>::prepare()
+template<> inline V8Parameter<DefaultMode>& V8Parameter<DefaultMode>::operator=(v8::Local<v8::Value> object)
 {
+    m_v8Object = object;
     prepareBase();
+    return *this;
 }
 
-template<> inline void V8Parameter<WithNullCheck>::prepare()
+template<> inline V8Parameter<WithNullCheck>& V8Parameter<WithNullCheck>::operator=(v8::Local<v8::Value> object)
 {
-    if (object().IsEmpty() || object()->IsNull()) {
+    m_v8Object = object;
+    if (m_v8Object.IsEmpty() || m_v8Object->IsNull())
         setString(String());
-        return;
-    }
-    prepareBase();
+    else
+        prepareBase();
+    return *this;
 }
 
-template<> inline void V8Parameter<WithUndefinedOrNullCheck>::prepare()
+template<> inline V8Parameter<WithUndefinedOrNullCheck>& V8Parameter<WithUndefinedOrNullCheck>::operator=(v8::Local<v8::Value> object)
 {
-    if (object().IsEmpty() || object()->IsNull() || object()->IsUndefined()) {
+    m_v8Object = object;
+    if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined())
         setString(String());
-        return;
-    }
-    prepareBase();
+    else
+        prepareBase();
+    return *this;
 }
     
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to