Skip to content
Browse files

Fixes for node HEAD

  • Loading branch information...
1 parent 105d2bb commit 302d0385429c1bc31deccf2046cdac5a8eb4ac80 @felixge committed Mar 27, 2010
Showing with 16 additions and 11 deletions.
  1. +9 −7 lib/ugly.js
  2. +1 −1 lib/worker/php.php
  3. +4 −1 test/common.js
  4. +2 −2 test/test-ugly.js
View
16 lib/ugly.js
@@ -3,10 +3,8 @@ var
path = require('path');
exports.createClient = function(options) {
- options = process.mixin({
- worker: __dirname+'/worker/php.php',
- }, options);
-
+ options = (options || {});
+ options.worker = options.worker || __dirname+'/worker/php.php';
var
client = {
onClose: function() {},
@@ -24,7 +22,7 @@ exports.createClient = function(options) {
while ((offset = buffer.indexOf("\n")) >= 0) {
response = buffer.substr(0, offset);
- // p('< '+response);
+ // puts('< '+response);
callback = callbacks.shift();
if (callback === undefined) {
@@ -40,7 +38,11 @@ exports.createClient = function(options) {
}
if (response.error) {
- callback(process.mixin(new Error, response));
+ var err = new Error();
+ for (var key in response) {
+ err[key] = response[key];
+ }
+ callback(err);
} else {
callback(null, response);
}
@@ -69,7 +71,7 @@ exports.createClient = function(options) {
callbacks.push(callback);
message = JSON.stringify(args)+"\n";
- // p('> '+message);
+ // puts('> '+message);
worker.write(message, 'utf8');
};
View
2 lib/worker/php.php
@@ -28,7 +28,7 @@ public function work() {
if ($fn == 'eval' || is_callable($fn)) {
ob_start();
if ($fn == 'eval') {
- $val = eval('return '.$args[0]);
+ $val = eval($args[0]);
} else {
$val = call_user_func_array($fn, $args);
}
View
5 test/common.js
@@ -1,4 +1,7 @@
-process.mixin(require('sys'));
+var sys = require('sys');
+
+global.p = sys.p;
+global.puts = sys.puts;
global.php = require('../lib/ugly').createClient();
global.assert = require('assert');
View
4 test/test-ugly.js
@@ -15,8 +15,8 @@ for (var i = 0; i < 10; i++) {
}
// This is pretty bad, even by ugly standards : )
-php.invoke('eval', 'new SimpleXMLElement("<test><hello>world</hello></test>");', function(e, r) {
- php.invoke('eval', '$ref["'+r.reference+'"]->hello;', function(e, r) {
+php.invoke('eval', 'return new SimpleXMLElement("<test><hello>world</hello></test>");', function(e, r) {
+ php.invoke('eval', 'return $ref["'+r.reference+'"]->hello;', function(e, r) {
assert.equal('world', r.val);
xmlCallback = true;
php.close();

0 comments on commit 302d038

Please sign in to comment.
Something went wrong with that request. Please try again.