Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Fix OS X stdout, stdin, and stderr.
Browse files Browse the repository at this point in the history
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).

#12496
  • Loading branch information
ariya committed Aug 22, 2014
1 parent 9e832a1 commit 51c8c9c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
24 changes: 24 additions & 0 deletions src/modules/system.js
Expand Up @@ -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;
}
});
6 changes: 3 additions & 3 deletions src/system.h
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions test/module/system/stderr.js
@@ -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');
7 changes: 7 additions & 0 deletions test/module/system/stdin.js
@@ -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');
8 changes: 8 additions & 0 deletions test/module/system/stdout.js
@@ -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');

0 comments on commit 51c8c9c

Please sign in to comment.