OLD | NEW |
| (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 /** | |
6 * A collection of helper io functions implemented using node.js. | |
7 * | |
8 * Idea is to clone the node.js API as closely as possible while adding types. | |
9 * Dart libraries on top of this will experiment with different APIs. | |
10 */ | |
11 #library('node'); | |
12 | |
13 // The sandbox needs to import the constructor functions for all the non-hidden
native types we use. | |
14 | |
15 var createSandbox() native | |
16 """return {'require': require, 'process': process, 'console': console, | |
17 'Buffer' : Buffer, | |
18 'setTimeout\$': this.setTimeout, 'clearTimeout': clearTimeout};"""; | |
19 | |
20 typedef void RequestListener(ServerRequest request, ServerResponse response); | |
21 | |
22 // TODO(nweiz): properly title-case these class names | |
23 | |
24 class http native "require('http')" { | |
25 static Server createServer(RequestListener listener) native; | |
26 } | |
27 | |
28 class Server native "http.Server" { | |
29 void listen(int port, [String hostname, Function callback]) native; | |
30 } | |
31 | |
32 class ServerRequest native "http.IncomingMessage" { | |
33 final String method; | |
34 final String url; | |
35 final Map<String, String> headers; | |
36 final String httpVersion; | |
37 | |
38 void setEncoding([String encoding]) {} | |
39 } | |
40 | |
41 class ServerResponse native "http.ServerResponse" { | |
42 int statusCode; | |
43 | |
44 void setHeader(String name, String value) native; | |
45 | |
46 String getHeader(String name) native; | |
47 | |
48 void removeHeader(String name) native; | |
49 | |
50 void write(String data, [String encoding = 'utf8']) native; | |
51 | |
52 void end([String data, String encoding = 'utf8']) native; | |
53 } | |
54 | |
55 class Console native "Console" { | |
56 // TODO(jimhug): Map node.js's ability to take multiple args to what? | |
57 void log(String text) native; | |
58 void info(String text) native; | |
59 void warn(String text) native; | |
60 void error(String text) native; | |
61 void dir(Object obj) native; | |
62 void time(String label) native; | |
63 void timeEnd(String label) native; | |
64 void trace() native; | |
65 void assert(bool value, [String message]) native; | |
66 } | |
67 | |
68 Console get console() | |
69 native "return console;"; | |
70 | |
71 /** | |
72 Implement as much of EventEmitter polymorphically as is possible, | |
73 given that frogsh function objects do not interoperate perfectly with | |
74 JavaScript function objects | |
75 */ | |
76 | |
77 // typedef EventListener([arg1, arg2, arg3]); | |
78 | |
79 interface EventEmitter { | |
80 // void addListener(String event, EventListener listener); | |
81 // void on(String event, EventListener listener); | |
82 // void once(String event, EventListener listener); | |
83 // void removeListener(String event, EventListener listener); | |
84 // List<EventListener> listeners(String event); | |
85 void removeAllListeners(String event); | |
86 void setMaxListeners(num n); | |
87 // TODO(jackpal): use rest arguments | |
88 void emit(String event, [var arg1, var arg2, var arg3]); | |
89 } | |
90 | |
91 typedef void ProcessExitListener(); | |
92 typedef void ProcessUncaughtExceptionListener(Exception err); | |
93 typedef void ProcessSignalListener(); | |
94 | |
95 class Process implements EventEmitter native "Process" { | |
96 var _process; | |
97 | |
98 // Note: This is not an exhaustive list of signals. Check with your | |
99 // OS documentation for sigaction to see which signals are | |
100 // available in your OS. | |
101 | |
102 final SIGHUP='SIGHUP'; | |
103 final SIGINT='SIGINT'; | |
104 final SIGQUIT='SIGQUIT'; | |
105 final SIGILL='SIGILL'; | |
106 final SIGTRAP='SIGTRAP'; | |
107 final SIGABRT='SIGABRT'; | |
108 final SIGEMT='SIGEMT'; | |
109 final SIGFPE='SIGFPE'; | |
110 final SIGKILL='SIGKILL'; | |
111 final SIGBUS='SIGBUS'; | |
112 final SIGSEGV='SIGSEGV'; | |
113 final SIGSYS='SIGSYS'; | |
114 final SIGPIPE='SIGPIPE'; | |
115 final SIGALRM='SIGALRM'; | |
116 final SIGTERM='SIGTERM'; | |
117 final SIGURG='SIGURG'; | |
118 final SIGSTOP='SIGSTOP'; | |
119 final SIGTSTP='SIGTSTP'; | |
120 final SIGCONT='SIGCONT'; | |
121 final SIGCHLD='SIGCHLD'; | |
122 final SIGTTIN='SIGTTIN'; | |
123 final SIGTTOU='SIGTTOU'; | |
124 final SIGIO='SIGIO'; | |
125 final SIGXCPU='SIGXCPU'; | |
126 final SIGXFSZ='SIGXFSZ'; | |
127 final SIGVTALRM='SIGVTALRM'; | |
128 final SIGPROF='SIGPROF'; | |
129 final SIGWINCH='SIGWINCH'; | |
130 final SIGINFO='SIGINFO'; | |
131 final SIGUSR1='SIGUSR1'; | |
132 final SIGUSR2='SIGUSR2'; | |
133 | |
134 Process(var this._process); | |
135 | |
136 // Implement EventEmitter | |
137 void removeAllListeners(String event) | |
138 native "this._process.removeAllListeners(event);"; | |
139 void setMaxListeners(num n) | |
140 native "this._process.setMaxListeners(n);"; | |
141 void emit(String event, [var arg1, var arg2, var arg3]) | |
142 native "this._process.emit(event, arg1, arg2, arg3)"; | |
143 | |
144 // Exit event | |
145 void emitExit() | |
146 native "this._process.emit('exit');"; | |
147 void addListenerExit(ProcessExitListener listener) | |
148 native "this._process.addListener('exit', listener);"; | |
149 void onExit(ProcessExitListener listener) | |
150 native "this._process.on('exit', listener);"; | |
151 void onceExit(ProcessExitListener listener) | |
152 native "this._process.once('exit', listener);"; | |
153 void removeListenerExit(ProcessExitListener listener) | |
154 native "this._process.removeListener('exit', listener);"; | |
155 List<ProcessExitListener> listenersExit() | |
156 native "return this._process.listeners('exit');"; | |
157 | |
158 // UncaughtException event | |
159 void emitUncaughtException(Exception err) | |
160 native "this._process.emit('uncaughtException', err);"; | |
161 void addListenerUncaughtException(ProcessUncaughtExceptionListener listener) | |
162 native "this._process.addListener('uncaughtException', listener);"; | |
163 void onUncaughtException(ProcessUncaughtExceptionListener listener) | |
164 native "this._process.on('uncaughtException', listener);"; | |
165 void onceUncaughtException(ProcessUncaughtExceptionListener listener) | |
166 native "this._process.once('uncaughtException', listener);"; | |
167 void removeListenerUncaughtException( | |
168 ProcessUncaughtExceptionListener listener) | |
169 native "this._process.removeListener('uncaughtException', listener);"; | |
170 List<ProcessUncaughtExceptionListener> listenersUncaughtException() | |
171 native "return this._process.listeners('uncaughtException');"; | |
172 | |
173 // Signal events | |
174 void emitSignal(String signal) | |
175 native "this._process.emit(signal);"; | |
176 void addListenerSignal(String signal, ProcessSignalListener listener) | |
177 native "this._process.addListener(signal, listener);"; | |
178 void onSignal(String signal, ProcessSignalListener listener) | |
179 native "this._process.on(signal, listener);"; | |
180 void onceSignal(String signal, ProcessSignalListener listener) | |
181 native "this._process.once(signal, listener);"; | |
182 void removeListenerSignal(String signal, ProcessSignalListener listener) | |
183 native "this._process.removeListener(signal, listener);"; | |
184 List<ProcessSignalListener> listenersSignal(String signal) | |
185 native "return this._process.listeners(signal);"; | |
186 | |
187 WritableStream get stdout() | |
188 native "return this._process.stdout;"; | |
189 WritableStream get stderr() | |
190 native "return this._process.stderr;"; | |
191 ReadableStream get stdin() | |
192 native "return this._process.stdin;"; | |
193 | |
194 List<String> get argv() | |
195 native "return this._process.argv;"; | |
196 void set argv(List<String> value) | |
197 native "this._process.argv = value;"; | |
198 String get execPath() | |
199 native "return this._process.execPath;"; | |
200 String chdir(String directory) | |
201 native "this._process.chdir(directory);"; | |
202 | |
203 String cwd() | |
204 native "return this._process.cwd();"; | |
205 | |
206 EnvMap get env() => new EnvMap(_process); | |
207 | |
208 void exit([int code = 0]) | |
209 native "this._process.exit(code);"; | |
210 int getgid() | |
211 native "return this._process.getgid();"; | |
212 void setgid(var gid_or_groupname) | |
213 native "this._process.setgid(uid_or_groupname);"; | |
214 int getuid() | |
215 native "return this._process.getuid();"; | |
216 void setuid(var uid_or_username) | |
217 native "this._process.setuid(uid_or_groupname);"; | |
218 String get version() | |
219 native "return this._process.version;"; | |
220 String get installPrefix() | |
221 native "return this._process.installPrefix;"; | |
222 void kill(int pid, [String signal=SIGTERM]) | |
223 native "this._process.kill(pid, signal);"; | |
224 int get pid() | |
225 native "return this._process.pid;"; | |
226 String get title() | |
227 native "return this._process.title;"; | |
228 String get platform() | |
229 native "return this._process.platform;"; | |
230 | |
231 // TODO(jackpal) implement Map memoryUsage() native; | |
232 void nextTick(Function callback) | |
233 native "return this._process.nextTick(callback);"; | |
234 int umask([int mask]) | |
235 native "return this._process.umask(mask);"; | |
236 } | |
237 | |
238 var get _process() | |
239 native "return process;"; | |
240 | |
241 Process get process() { | |
242 return new Process(_process); | |
243 } | |
244 | |
245 class EnvMap { | |
246 var _process; | |
247 const EnvMap(this._process); | |
248 operator [](key) native "return this._process.env[key];"; | |
249 | |
250 } | |
251 | |
252 typedef void UtilPumpCallback(var error); | |
253 | |
254 class util native "require('util')" { | |
255 static void debug(String string) native; | |
256 static void log(String string) native; | |
257 static void inspect(var object, [bool showHidden=false, num depth=2]) native; | |
258 static pump(ReadableStream readableStream, WritableStream writeableStream, | |
259 [UtilPumpCallback callback]) native; | |
260 // the method inherits(a,b) doesn't make sense for Dart | |
261 } | |
262 | |
263 // Object is either a Buffer or a String, depending upon whether setEncoding has
been called. | |
264 typedef void ReadableStreamDataListener(var object); | |
265 typedef void ReadableStreamEndListener(); | |
266 typedef void ReadableStreamErrorListener(Object exception); | |
267 typedef void ReadableStreamCloseListener(); | |
268 | |
269 class ReadableStream implements EventEmitter native "*ReadStream" { | |
270 // EventEmitter | |
271 void removeAllListeners(String event) native; | |
272 void setMaxListeners(num n) native; | |
273 void emit(String event, [var arg1, var arg2, var arg3]) native; | |
274 | |
275 // Data event | |
276 void emitData(var data) | |
277 native "this.emit('data', data);"; | |
278 void addListenerData(ReadableStreamDataListener listener) | |
279 native "this.addListener('data', listener);"; | |
280 void onData(ReadableStreamDataListener listener) | |
281 native "this.on('data', listener);"; | |
282 void onceData(ReadableStreamDataListener listener) | |
283 native "this.once('data', listener);"; | |
284 void removeListenerData(ReadableStreamDataListener listener) | |
285 native "this.removeListener('data', listener);"; | |
286 List<ReadableStreamDataListener> listenersData() | |
287 native "return this._process.listeners('data');"; | |
288 | |
289 // End event | |
290 void emitEnd() | |
291 native "this.emit('end');"; | |
292 void addListenerEnd(ReadableStreamEndListener listener) | |
293 native "this.addListener('end', listener);"; | |
294 void onEnd(ReadableStreamEndListener listener) | |
295 native "this.on('end', listener);"; | |
296 void onceEnd(ReadableStreamEndListener listener) | |
297 native "this.once('end', listener);"; | |
298 void removeListenerEnd(ReadableStreamEndListener listener) | |
299 native "this.removeListener('end', listener);"; | |
300 List<ReadableStreamEndListener> listenersEnd() | |
301 native "return this._process.listeners('end');"; | |
302 | |
303 // Error event | |
304 void emitError(Object exception) | |
305 native "this.emit('error', exception);"; | |
306 void addListenerError(ReadableStreamErrorListener listener) | |
307 native "this.addListener('error', listener);"; | |
308 void onError(ReadableStreamErrorListener listener) | |
309 native "this.on('error', listener);"; | |
310 void onceError(ReadableStreamErrorListener listener) | |
311 native "this.once('error', listener);"; | |
312 void removeListenerError(ReadableStreamErrorListener listener) | |
313 native "this.removeListener('error', listener);"; | |
314 List<ReadableStreamErrorListener> listenersError() | |
315 native "return this._process.listeners('error');"; | |
316 | |
317 // Close event | |
318 void emitClose() | |
319 native "this.emit('close');"; | |
320 void addListenerClose(ReadableStreamCloseListener listener) | |
321 native "this.addListener('close', listener);"; | |
322 void onClose(ReadableStreamCloseListener listener) | |
323 native "this.on('close', listener);"; | |
324 void onceClose(ReadableStreamCloseListener listener) | |
325 native "this.once('close', listener);"; | |
326 void removeListenerClose(ReadableStreamCloseListener listener) | |
327 native "this.removeListener('close', listener);"; | |
328 List<ReadableStreamCloseListener> listenersClose() | |
329 native "return this._process.listeners('close');"; | |
330 | |
331 bool readable; | |
332 void setEncoding(String encoding) native; | |
333 void pause() native; | |
334 void resume() native; | |
335 void destroy() native; | |
336 void destroySoon() native; | |
337 void pipe(WritableStream destination, [bool end=true]) | |
338 native "this.pipe(destination, {'end': end});"; | |
339 } | |
340 | |
341 typedef void WritableStreamDrainListener(); | |
342 typedef void WritableStreamErrorListener(Object exception); | |
343 typedef void WritableStreamCloseListener(); | |
344 typedef void WritableStreamPipeListener(ReadableStream src); | |
345 | |
346 class WritableStream implements EventEmitter native "*WriteStream" { | |
347 // EventEmitter | |
348 void removeAllListeners(String event) native "this._writeStream.removeAllListe
ners(event);"; | |
349 void setMaxListeners(num n) native; | |
350 void emit(String event, [var arg1, var arg2, var arg3]) native; | |
351 | |
352 // Drain event | |
353 void emitDrain() | |
354 native "this.emit('drain');"; | |
355 void addListenerDrain(WritableStreamDrainListener listener) | |
356 native "this.addListener('drain', listener);"; | |
357 void onDrain(WritableStreamDrainListener listener) | |
358 native "this.on('drain', listener);"; | |
359 void onceDrain(WritableStreamDrainListener listener) | |
360 native "this.once('drain', listener);"; | |
361 void removeListenerDrain(WritableStreamDrainListener listener) | |
362 native "this.removeListener('drain', listener);"; | |
363 List<WritableStreamDrainListener> listenersDrain() | |
364 native "return this._process.listeners('drain');"; | |
365 | |
366 // Error event | |
367 void emitError(Object exception) | |
368 native "this.emit('error', exception);"; | |
369 void addListenerError(WritableStreamErrorListener listener) | |
370 native "this.addListener('error', listener);"; | |
371 void onError(WritableStreamErrorListener listener) | |
372 native "this.on('error', listener);"; | |
373 void onceError(WritableStreamErrorListener listener) | |
374 native "this.once('error', listener);"; | |
375 void removeListenerError(WritableStreamErrorListener listener) | |
376 native "this.removeListener('error', listener);"; | |
377 List<WritableStreamErrorListener> listenersError() | |
378 native "return this._process.listeners('error');"; | |
379 | |
380 // Close event | |
381 void emitClose() | |
382 native "this.emit('close');"; | |
383 void addListenerClose(WritableStreamCloseListener listener) | |
384 native "this.addListener('close', listener);"; | |
385 void onClose(WritableStreamCloseListener listener) | |
386 native "this.on('close', listener);"; | |
387 void onceClose(WritableStreamCloseListener listener) | |
388 native "this.once('close', listener);"; | |
389 void removeListenerClose(WritableStreamCloseListener listener) | |
390 native "this.removeListener('close', listener);"; | |
391 List<WritableStreamCloseListener> listenersClose() | |
392 native "return this._process.listeners('close');"; | |
393 | |
394 // Pipe event | |
395 void emitPipe(ReadableStream src) | |
396 native "this.emit('pipe', src);"; | |
397 void addListenerPipe(WritableStreamPipeListener listener) | |
398 native "this.addListener('pipe', listener);"; | |
399 void onPipe(WritableStreamPipeListener listener) | |
400 native "this.on('pipe', listener);"; | |
401 void oncePipe(WritableStreamPipeListener listener) | |
402 native "this.once('pipe', listener);"; | |
403 void removeListenerPipe(WritableStreamPipeListener listener) | |
404 native "this.removeListener('pipe', listener);"; | |
405 List<WritableStreamPipeListener> listenersPipe() | |
406 native "return this._process.listeners('pipe');"; | |
407 | |
408 bool writable; | |
409 bool write(String string, [String encoding='utf8', int fd]) native; | |
410 bool writeBuffer(Buffer buffer) native; | |
411 void end([String string, String encoding='utf8']) native; | |
412 void endBuffer(Buffer buffer) native "this.end(buffer);"; | |
413 void destroy() native; | |
414 void destroySoon() native; | |
415 } | |
416 | |
417 class vm native "require('vm')" { | |
418 static void runInThisContext(String code, [String filename]) native; | |
419 static void runInNewContext(String code, [var sandbox, String filename]) | |
420 native; | |
421 static Script createScript(String code, [String filename]) native; | |
422 static Context createContext([sandbox]) native; | |
423 static runInContext(String code, Context context, [String filename]) native; | |
424 } | |
425 | |
426 interface Context {} | |
427 | |
428 class Script native "vm.Script" { | |
429 void runInThisContext() native; | |
430 void runInNewContext([Map sandbox]) native; | |
431 } | |
432 | |
433 class fs native "require('fs')" { | |
434 static void writeFileSync(String outfile, String text) native; | |
435 | |
436 static String readFileSync(String filename, [String encoding = 'utf8']) | |
437 native; | |
438 | |
439 static String realpathSync(String path) native; | |
440 | |
441 static void mkdirSync(String path, [num mode = 511 /* 0777 octal */]) native; | |
442 static List<String> readdirSync(String path) native; | |
443 static void rmdirSync(String path) native; | |
444 static Stats statSync(String path) native; | |
445 static void unlinkSync(String path) native; | |
446 | |
447 static void writeSync(int fd, String text) native; | |
448 static int openSync(String path, String flags, | |
449 [num mode = 438] /* 0666 octal */) native; | |
450 static void closeSync(int fd) native; | |
451 } | |
452 | |
453 class Stats native "fs.Stats" { | |
454 bool isFile() native; | |
455 bool isDirectory() native; | |
456 bool isBlockDevice() native; | |
457 bool isCharacterDevice() native; | |
458 bool isSymbolicLink() native; | |
459 bool isFIFO() native; | |
460 bool isSocket() native; | |
461 | |
462 // TODO(rnystrom): There are also the other fields we can add here if needed. | |
463 // See: http://nodejs.org/docs/v0.6.1/api/fs.html#fs.Stats. | |
464 } | |
465 | |
466 class path native "require('path')" { | |
467 static bool existsSync(String filename) native; | |
468 static String dirname(String path) native; | |
469 static String basename(String path) native; | |
470 static String extname(String path) native; | |
471 static String normalize(String path) native; | |
472 // TODO(jimhug): Get the right signatures for normalizeArray and join | |
473 } | |
474 | |
475 class Readline native "require('readline')" { | |
476 static ReadlineInterface createInterface(input, output) native; | |
477 } | |
478 | |
479 class ReadlineInterface native "Readline.Interface" { | |
480 void setPrompt(String prompt, [int length]) native; | |
481 void prompt() native; | |
482 void on(String event, Function callback) native; | |
483 } | |
484 | |
485 interface TimeoutId {} | |
486 | |
487 TimeoutId setTimeout(Function callback, num delay, [arg]) native; | |
488 clearTimeout(TimeoutId id) native; | |
489 | |
490 typedef void ChildProcessExitListener(int code, String signal); | |
491 | |
492 class ChildProcess implements EventEmitter native "ChildProcess" { | |
493 var _childprocess; | |
494 | |
495 ChildProcess(this._childprocess); | |
496 | |
497 // EventEmitter | |
498 void removeAllListeners(String event) | |
499 native "this._childprocess.removeAllListeners(event);"; | |
500 void setMaxListeners(num n) | |
501 native "this._childprocess.setMaxListeners(n);"; | |
502 void emit(String event, [var arg1, var arg2, var arg3]) | |
503 native "this._childprocess.emit(event, arg1, arg2, arg3);"; | |
504 | |
505 // 'exit' event | |
506 void addListenerExit(ChildProcessExitListener listener) | |
507 native "this._childprocess.addListener('exit', listener);"; | |
508 void onExit(ChildProcessExitListener listener) | |
509 native "this._childprocess.on('exit', listener);"; | |
510 void onceExit(ChildProcessExitListener listener) | |
511 native "this._childprocess.once('exit', listener);"; | |
512 void removeListenerExit(ChildProcessExitListener listener) | |
513 native "this._childprocess.removeListener('exit', listener);"; | |
514 List<ChildProcessExitListener> listenersExit() | |
515 native "return this._childprocess.listeners('exit');"; | |
516 | |
517 WritableStream get stdin() | |
518 native "return this._childprocess.stdin;"; | |
519 | |
520 ReadableStream get stdout() | |
521 native "return this._childprocess.stdout;"; | |
522 ReadableStream get stderr() | |
523 native "return this._childprocess.stderr;"; | |
524 int get pid() | |
525 native "return this._childprocess.pid;"; | |
526 } | |
527 | |
528 typedef void Child_processCallback(Error error, String stdout, String stderr); | |
529 | |
530 class Child_process native { | |
531 var _cp; | |
532 | |
533 Child_process() { | |
534 _cp = _get_child_process(); | |
535 } | |
536 | |
537 // TODOO(jackpal): translate options into a Javascript dictionary | |
538 ChildProcess spawn(String command, [List<String> args, | |
539 Map<String, Object> options]){ | |
540 return new ChildProcess(_spawn(_cp, command, args)); | |
541 } | |
542 | |
543 // TODOO(jackpal): translate options into a Javascript dictionary | |
544 ChildProcess exec(String command, Child_processCallback callback, | |
545 [Map<String, Object> options]) { | |
546 // Note the argument order to exec is different than to _exec, | |
547 // because Dart can't have optional arguments in the middle of | |
548 // an argument list. | |
549 return new ChildProcess(_exec(_cp, command, options, callback)); | |
550 } | |
551 | |
552 static var _spawn(var cp, String command, List<String> args) | |
553 native "return cp.spawn(command, args);"; | |
554 static var _exec(var cp, String command, Map<String, Object> options, | |
555 Child_processCallback callback) | |
556 native "return cp.exec(command, options, callback);"; | |
557 | |
558 static var _get_child_process() | |
559 native "return require('child_process');"; | |
560 } | |
561 | |
562 var get child_process() { | |
563 return new Child_process(); | |
564 } | |
565 | |
566 class Buffer native "Buffer" { | |
567 Buffer(int size) native; | |
568 Buffer.fromSize(int size) | |
569 native "return new Buffer(size);"; | |
570 Buffer.fromList(List<int> list) | |
571 native "return new Buffer(list);"; | |
572 Buffer.fromString(String string, [String encoding='utf8']) | |
573 native "return new Buffer(string, encoding);"; | |
574 // the default length is buffer.length-offset | |
575 int write(String string, int offset, int length, [String encoding='utf8']) | |
576 native; | |
577 static int get charsWritten() | |
578 native "return Buffer._charsWritten;"; | |
579 String toString(String encoding, int start, int end) native; | |
580 int operator[](int index) | |
581 native "return this[index];"; | |
582 int operator[]=(int index, int value) | |
583 native "this[index] = value; return value;"; | |
584 static bool isBuffer(obj) native; | |
585 static int byteLength(String string, [String encoding='utf8']) native; | |
586 int length; | |
587 void copy(Buffer targetBuffer, int targetStart, int sourceStart, int sourceEnd
) native; | |
588 Buffer slice(int start, int end) native; | |
589 | |
590 int readUInt8(int offset, [bool noAssert=false]) native; | |
591 int readUInt16LE(int offset, [bool noAssert=false]) native; | |
592 int readUInt16BE(int offset, [bool noAssert=false]) native; | |
593 int readUInt32LE(int offset, [bool noAssert=false]) native; | |
594 int readUInt32BE(int offset, [bool noAssert=false]) native; | |
595 | |
596 int readInt8(int offset, [bool noAssert=false]) native; | |
597 int readInt16LE(int offset, [bool noAssert=false]) native; | |
598 int readInt16BE(int offset, [bool noAssert=false]) native; | |
599 int readInt32LE(int offset, [bool noAssert=false]) native; | |
600 int readInt32BE(int offset, [bool noAssert=false]) native; | |
601 | |
602 double readFloatLE(int offset, [bool noAssert=false]) native; | |
603 double readFloatBE(int offset, [bool noAssert=false]) native; | |
604 double readDoubleLE(int offset, [bool noAssert=false]) native; | |
605 double readDoubleBE(int offset, [bool noAssert=false]) native; | |
606 | |
607 void writeUInt8(int value, int offset, [bool noAssert=false]) native; | |
608 void writeUInt16LE(int value, int offset, [bool noAssert=false]) native; | |
609 void writeUInt16BE(int value, int offset, [bool noAssert=false]) native; | |
610 void writeUInt32LE(int value, int offset, [bool noAssert=false]) native; | |
611 void writeUInt32BE(int value, int offset, [bool noAssert=false]) native; | |
612 | |
613 void writeInt8(int value, int offset, [bool noAssert=false]) native; | |
614 void writeInt16LE(int value, int offset, [bool noAssert=false]) native; | |
615 void writeInt16BE(int value, int offset, [bool noAssert=false]) native; | |
616 void writeInt32LE(int value, int offset, [bool noAssert=false]) native; | |
617 void writeInt32BE(int value, int offset, [bool noAssert=false]) native; | |
618 | |
619 void writeFloatLE(double value, int offset, [bool noAssert=false]) native; | |
620 void writeFloatBE(double value, int offset, [bool noAssert=false]) native; | |
621 void writeDoubleLE(double value, int offset, [bool noAssert=false]) native; | |
622 void writeDoubleBE(double value, int offset, [bool noAssert=false]) native; | |
623 | |
624 // end defaults to buffer.length | |
625 void fill(int value, int offset, int end) native; | |
626 | |
627 static int INSPECT_MAX_BYTES; | |
628 } | |
629 | |
630 class Error native "Error" { | |
631 var stack; | |
632 var arguments; | |
633 var type; | |
634 String message; | |
635 bool killed; | |
636 int code; | |
637 String signal; | |
638 } | |
OLD | NEW |