Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: frog/lib/node/child_process.dart

Issue 9034014: Add support for the node net module. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: new version of minfrog Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('child_process');
6 #import('node.dart');
7 #import('net.dart');
8
9 typedef void ChildProcessExitListener(int code, String signal);
10
11 class ChildProcess implements EventEmitter native "ChildProcess" {
12 var _childprocess;
13
14 ChildProcess(this._childprocess);
15
16 // EventEmitter
17 void removeAllListeners(String event)
18 native "this._childprocess.removeAllListeners(event);";
19 void setMaxListeners(num n)
20 native "this._childprocess.setMaxListeners(n);";
21 var _listeners(String key)
22 native "return this._childprocess.listeners(key);";
23
24 // 'exit' event
25 void emitExit(int code, String signal)
26 native "this._childprocess.emit('exit', code, signal);";
27 void addListenerExit(ChildProcessExitListener listener)
28 native "this._childprocess.addListener('exit', listener);";
29 void onExit(ChildProcessExitListener listener)
30 native "this._childprocess.on('exit', listener);";
31 void onceExit(ChildProcessExitListener listener)
32 native "this._childprocess.once('exit', listener);";
33 void removeListenerExit(ChildProcessExitListener listener)
34 native "this._childprocess.removeListener('exit', listener);";
35 List<ChildProcessExitListener> listenersExit()
36 => new _NativeListPrimitiveElement<ChildProcessExitListener>(
37 _listeners('exit'));
38
39 Socket get stdin()
40 native "return this._childprocess.stdin;";
41 Socket get stdout()
42 native "return this._childprocess.stdout;";
43 Socket get stderr()
44 native "return this._childprocess.stderr;";
45 int get pid()
46 native "return this._childprocess.pid;";
47 }
48
49 typedef void Child_processCallback(Error error, String stdout, String stderr);
50
51 class Child_process native {
52 var _cp;
53
54 Child_process() {
55 _cp = _child_process;
56 }
57
58 // TODOO(jackpal): translate options into a Javascript dictionary
59 ChildProcess spawn(String command, [List<String> args,
60 Map<String, Object> options]){
61 return new ChildProcess(_spawn(_cp, command, args, options));
62 }
63
64 // TODOO(jackpal): translate options into a Javascript dictionary
65 ChildProcess exec(String command, Child_processCallback callback,
66 [Map<String, Object> options]) {
67 // Note the argument order to exec is different than to _exec,
68 // because Dart can't have optional arguments in the middle of
69 // an argument list.
70 return new ChildProcess(_exec(_cp, command, options, callback));
71 }
72
73 static var _spawn(var cp, String command, List<String> args)
74 native "return cp.spawn(command, args);";
75 static var _exec(var cp, String command, Map<String, Object> options,
76 Child_processCallback callback)
77 native "return cp.exec(command, options, callback);";
78 static var get _child_process() native "return require('child_process')";
79 }
80
81 var get child_process() {
82 return new Child_process();
83 }
OLDNEW
« no previous file with comments | « frog/file_system_node.dart ('k') | frog/lib/node/cluster.dart » ('j') | frog/lib/node/net.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698