Fix OS X stdout, stdin, and stderr.

To prevent unintended macro expansion, don't use the name
stdout/stdin/stderr in the native System object. Those properties are
achieved by shadowing it in the module interface (JavaScript side).

https://github.com/ariya/phantomjs/issues/12496
2.0
Ariya Hidayat 2014-08-22 07:56:40 -07:00
parent 9e832a1569
commit 51c8c9cc62
5 changed files with 50 additions and 3 deletions

View File

@ -4,3 +4,27 @@
*/
exports.platform = 'phantomjs';
Object.defineProperty(exports, 'stdout', {
enumerable: true,
writeable: false,
get: function() {
return exports.standardout;
}
});
Object.defineProperty(exports, 'stdin', {
enumerable: true,
writeable: false,
get: function() {
return exports.standardin;
}
});
Object.defineProperty(exports, 'stderr', {
enumerable: true,
writeable: false,
get: function() {
return exports.standarderr;
}
});

View File

@ -49,9 +49,9 @@ class System : public QObject
Q_PROPERTY(QVariant env READ env)
Q_PROPERTY(QVariant os READ os)
Q_PROPERTY(bool isSSLSupported READ isSSLSupported)
Q_PROPERTY(QObject *stdout READ _stdout)
Q_PROPERTY(QObject *stderr READ _stderr)
Q_PROPERTY(QObject *stdin READ _stdin)
Q_PROPERTY(QObject *standardout READ _stdout)
Q_PROPERTY(QObject *standarderr READ _stderr)
Q_PROPERTY(QObject *standardin READ _stdin)
public:
explicit System(QObject *parent = 0);

View File

@ -0,0 +1,8 @@
var assert = require('../../assert');
var system = require('system');
assert.typeOf(system.stderr, 'object');
assert.typeOf(system.stderr.write, 'function');
assert.typeOf(system.stderr.writeLine, 'function');
assert.typeOf(system.stderr.flush, 'function');
assert.typeOf(system.stderr.close, 'function');

View File

@ -0,0 +1,7 @@
var assert = require('../../assert');
var system = require('system');
assert.typeOf(system.stdin, 'object');
assert.typeOf(system.stdin.read, 'function');
assert.typeOf(system.stdin.readLine, 'function');
assert.typeOf(system.stdin.close, 'function');

View File

@ -0,0 +1,8 @@
var assert = require('../../assert');
var system = require('system');
assert.typeOf(system.stdout, 'object');
assert.typeOf(system.stdout.write, 'function');
assert.typeOf(system.stdout.writeLine, 'function');
assert.typeOf(system.stdout.flush, 'function');
assert.typeOf(system.stdout.close, 'function');