Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // module os | |
| 2 | |
| 3 #library('os'); | |
| 4 #import('node.dart'); | |
| 5 #import('nodeimpl.dart'); | |
| 6 | |
| 7 class Os { | |
|
Jennifer Messerly
2012/01/21 01:00:31
This is another class where I'm not sure if wrappi
| |
| 8 var _os; | |
| 9 Os(this._os); | |
| 10 String hostname() native "return this._os.hostname();"; | |
| 11 String type() native "return this._os.type();"; | |
| 12 String platform() native "return this._os.platform();"; | |
| 13 String arch() native "return this._os.arch();"; | |
| 14 String release() native "return this._os.release();"; | |
| 15 int uptime() native "return this._os.uptime();"; | |
| 16 List<double> loadAvg() => new NativeListPrimitiveElement<double>(_loadavg()); | |
| 17 var _loadavg() native "return this._os.loadavg();"; | |
| 18 int totalmem() native "return this._os.totalmem();"; | |
| 19 int freemem() native "return this._os.freemem();"; | |
| 20 List<OsCpu> cpus() => new _NativeList<OsCpu>(_cpus(), | |
| 21 (cpu) => new OsCpu(cpu)); | |
| 22 var _cpus() native "return this._os.cpus()"; | |
|
Jennifer Messerly
2012/01/21 01:00:31
style nit: I'd leave off the "var" in return value
| |
| 23 Map<String, List<OsNetworkInterface>> networkInterfaces() => | |
| 24 new NativeMap<List<OsNetworkInterface>>(_netInts(), | |
| 25 (var netIntList) => new NativeList<OsNetworkInterface>(netIntList, | |
| 26 (var netInt) => new OsNetworkInterface(netInt))); | |
| 27 var _netInts() native "return this._os.networkInterfaces();"; | |
| 28 } | |
| 29 | |
| 30 Os get os() => new Os(require('os')); | |
| 31 | |
| 32 class OsLoadAvg { | |
| 33 var _loadavg; | |
| 34 OsLoadAvg(this._loadavg); | |
| 35 int get length() native "return this._loadavg.length;"; | |
| 36 double operator[](int index) native "return this._loadavg[index];"; | |
| 37 } | |
| 38 | |
| 39 class OsCpu { | |
| 40 var _cpu; | |
| 41 OsCpu(this._cpu); | |
| 42 String get model() native "return this._cpu.model;"; | |
| 43 int get speed() native "return this._cpu.speed;"; | |
| 44 OsCpuTimes get times() => new OsCpuTimes(_times()); | |
| 45 var _times() native "return this._cpu.times;"; | |
| 46 } | |
| 47 | |
| 48 class OsCpuTimes { | |
| 49 var _times; | |
| 50 OsCpuTimes(this._times); | |
| 51 int get user() native "return this._times.user;"; | |
| 52 int get nice() native "return this._times.nice;"; | |
| 53 int get sys() native "return this._times.sys;"; | |
| 54 int get idle() native "return this._times.idle;"; | |
| 55 int get irq() native "return this._times.irq;"; | |
| 56 } | |
| 57 | |
| 58 class OsNetworkInterface { | |
| 59 var _netInt; | |
| 60 OsNetworkInterface(this._netInt); | |
| 61 String get address() native "return this._netInt.address;"; | |
| 62 String get family() native "return this._netInt.family;"; | |
| 63 bool get internal() native "return this._netInt.internal;"; | |
| 64 } | |
| OLD | NEW |