Permalink
Browse files

Updated package.xml for today's release, added fix for 1.9 compilatio…

…n, added closure features test

git-svn-id: https://ookoo.org/svn/pecl-spidermonkey@56 a25dae62-eead-11dd-be30-d70757e1f724
  • Loading branch information...
1 parent 468880c commit 1672d1bbe3c9900c9f2a544d0adf47f36cb2b4e0 BombStrike committed Feb 23, 2010
Showing with 48 additions and 10 deletions.
  1. +6 −2 package.xml
  2. +6 −1 spidermonkey.c
  3. +30 −0 tests/feature16967.phpt
  4. +6 −7 tests/js_objects.phpt
View
8 package.xml
@@ -12,7 +12,7 @@
<email>crobin@php.net</email>
<active>yes</active>
</lead>
- <date>2010-02-21</date>
+ <date>2010-02-23</date>
<version>
<release>0.1.4</release><api>0.1.4</api>
</version>
@@ -42,12 +42,16 @@
<file name="tests/js_objects.phpt" role="test"/>
<file name="tests/js_streams.phpt" role="test"/>
<file name="tests/js_types.phpt" role="test"/>
+ <file name="tests/bug16866.phpt" role="test"/>
+ <file name="tests/bug16876.phpt" role="test"/>
+ <file name="tests/bug16890.phpt" role="test"/>
+ <file name="tests/bug16983.phpt" role="test"/>
</dir>
</contents>
<dependencies>
<required>
<php>
- <min>5.3.0beta1</min>
+ <min>5.3.0</min>
</php>
<pearinstaller>
<min>1.4.0</min>
View
7 spidermonkey.c
@@ -187,7 +187,9 @@ PHP_MINIT_FUNCTION(spidermonkey)
REGISTER_LONG_CONSTANT("JSOPTION_ATLINE", JSOPTION_ATLINE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("JSOPTION_COMPILE_N_GO", JSOPTION_COMPILE_N_GO, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("JSOPTION_DONT_REPORT_UNCAUGHT", JSOPTION_DONT_REPORT_UNCAUGHT, CONST_CS | CONST_PERSISTENT);
+#ifdef JSOPTION_NATIVE_BRANCH_CALLBACK
REGISTER_LONG_CONSTANT("JSOPTION_NATIVE_BRANCH_CALLBACK",JSOPTION_NATIVE_BRANCH_CALLBACK,CONST_CS | CONST_PERSISTENT);
+#endif
REGISTER_LONG_CONSTANT("JSOPTION_STRICT", JSOPTION_STRICT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("JSOPTION_VAROBJFIX", JSOPTION_VAROBJFIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("JSOPTION_WERROR", JSOPTION_WERROR, CONST_CS | CONST_PERSISTENT);
@@ -318,9 +320,12 @@ void _jsval_to_zval(zval *return_value, JSContext *ctx, jsval *jval, php_jsparen
zval *zobj;
php_jsparent jsthis;
- //if (JS_ValueToObject(ctx, rval, &obj) == JS_TRUE)
obj = JSVAL_TO_OBJECT(rval);
+ /*if (JS_ObjectIsFunction(ctx, obj)) {
+ // object is a function
+ }*/
+
/* your shouldn't be able to reference the global object */
if (obj == JS_GetGlobalObject(ctx)) {
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Trying to reference global object", 0 TSRMLS_CC);
View
30 tests/feature16967.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Feature request 16967 ( Export javascript functions from Javascript to PHP )
+--FILE--
+<?php
+
+$js = new JSContext;
+$window = new stdClass;
+$window->foo = function() { echo "bar"; };
+
+$js->assign('window', $window);
+
+$script = <<<JS
+ window.foo();
+
+ window.onload = function () {
+ return 'foobar';
+ };
+
+ window.onload();
+JS;
+
+var_dump($js->evaluateScript($script));
+var_dump($window->onload instanceof Closure);
+var_dump($window->onload);
+?>
+--EXPECTF--
+string(6) "foobar"
+bool(true)
+object(Closure)#3 (0) {
+}
View
13 tests/js_objects.phpt
@@ -25,16 +25,15 @@ a = {
SCR;
-$js->evaluateScript($script);
+try {
+ $js->evaluateScript($script);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
?>
--EXPECTF--
<?xml version="1.0"?>
<foo>
<bar bleh="blah">meh</bar>
</foo>
-
-Fatal error: Uncaught exception 'Exception' with message 'Trying to reference global object' in /home/bomb/Desktop/Code/C/spidermonkey/tests/js_objects.php:25
-Stack trace:
-#0 /home/bomb/Desktop/Code/C/spidermonkey/tests/js_objects.php(25): JSContext->evaluateScript('dom = new DOMDo...')
-#1 {main}
- thrown in /home/bomb/Desktop/Code/C/spidermonkey/tests/js_objects.php on line 25
+string(33) "Trying to reference global object"

0 comments on commit 1672d1b

Please sign in to comment.