Title: [113654] trunk/Source/_javascript_Core
Revision
113654
Author
[email protected]
Date
2012-04-09 18:41:25 -0700 (Mon, 09 Apr 2012)

Log Message

If a callback function returns a C++ null, convert to undefined.
https://bugs.webkit.org/show_bug.cgi?id=83534

Reviewed by Geoff Garen.

* API/JSCallbackFunction.cpp:
    - If a callback function returns a C++ null, convert to undefined.
(JSC::JSCallbackFunction::call):
* API/tests/testapi.c:
(Base_returnHardNull):
* API/tests/testapi.js:
    - Add a test case for callback functions that return a C++ null.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSCallbackFunction.cpp (113653 => 113654)


--- trunk/Source/_javascript_Core/API/JSCallbackFunction.cpp	2012-04-10 01:30:03 UTC (rev 113653)
+++ trunk/Source/_javascript_Core/API/JSCallbackFunction.cpp	2012-04-10 01:41:25 UTC (rev 113654)
@@ -77,7 +77,7 @@
 
     // result must be a valid JSValue.
     if (!result)
-        return throwVMTypeError(exec);
+        return JSValue::encode(jsUndefined());
 
     return JSValue::encode(toJS(exec, result));
 }

Modified: trunk/Source/_javascript_Core/API/tests/testapi.c (113653 => 113654)


--- trunk/Source/_javascript_Core/API/tests/testapi.c	2012-04-10 01:30:03 UTC (rev 113653)
+++ trunk/Source/_javascript_Core/API/tests/testapi.c	2012-04-10 01:41:25 UTC (rev 113654)
@@ -678,9 +678,22 @@
     return JSValueMakeNumber(ctx, 1); // distinguish base call from derived call
 }
 
+static JSValueRef Base_returnHardNull(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(ctx);
+    UNUSED_PARAM(function);
+    UNUSED_PARAM(thisObject);
+    UNUSED_PARAM(argumentCount);
+    UNUSED_PARAM(arguments);
+    UNUSED_PARAM(exception);
+    
+    return 0; // should convert to undefined!
+}
+
 static JSStaticFunction Base_staticFunctions[] = {
     { "baseProtoDup", NULL, kJSPropertyAttributeNone },
     { "baseProto", Base_callAsFunction, kJSPropertyAttributeNone },
+    { "baseHardNull", Base_returnHardNull, kJSPropertyAttributeNone },
     { 0, 0, 0 }
 };
 

Modified: trunk/Source/_javascript_Core/API/tests/testapi.js (113653 => 113654)


--- trunk/Source/_javascript_Core/API/tests/testapi.js	2012-04-10 01:30:03 UTC (rev 113653)
+++ trunk/Source/_javascript_Core/API/tests/testapi.js	2012-04-10 01:41:25 UTC (rev 113654)
@@ -186,6 +186,8 @@
 shouldBe("derived.protoDup", 2);
 shouldBe("derived.derivedOnly", 2)
 
+shouldBe("derived.baseHardNull()", undefined)
+
 // base properties throw 1 when set; derived, 2
 shouldBe("derived.baseDup = 0", 2);
 shouldBe("derived.baseOnly = 0", 1);

Modified: trunk/Source/_javascript_Core/ChangeLog (113653 => 113654)


--- trunk/Source/_javascript_Core/ChangeLog	2012-04-10 01:30:03 UTC (rev 113653)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-04-10 01:41:25 UTC (rev 113654)
@@ -1,3 +1,18 @@
+2012-04-09  Gavin Barraclough  <[email protected]>
+
+        If a callback function returns a C++ null, convert to undefined.
+        https://bugs.webkit.org/show_bug.cgi?id=83534
+
+        Reviewed by Geoff Garen.
+
+        * API/JSCallbackFunction.cpp:
+            - If a callback function returns a C++ null, convert to undefined.
+        (JSC::JSCallbackFunction::call):
+        * API/tests/testapi.c:
+        (Base_returnHardNull):
+        * API/tests/testapi.js:
+            - Add a test case for callback functions that return a C++ null.
+
 2012-04-09  Filip Pizlo  <[email protected]>
 
         Classic interpreter's GC hooks shouldn't attempt to scan instructions for code blocks that
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to