本文整理汇总了TypeScript中node-binary-marshal.Marshal函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Marshal函数的具体用法?TypeScript Marshal怎么用?TypeScript Marshal使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Marshal函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: cb
this.readdir((derr: any, files: string[]) => {
if (derr) {
console.log('readdir: ' + derr);
cb(-EFAULT);
return;
}
files = files.filter((s: string) => s !== '.deletedFiles.log');
files.sort();
files = files.slice(this.off);
let dents = files.map((n) => new fs.Dirent(-1, fs.DT.UNKNOWN, n));
let view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
let voff = 0;
for (let i = 0; i < dents.length; i++) {
let dent = dents[i];
if (voff + dent.reclen > buf.byteLength)
break;
let [len, err] = Marshal(view, voff, dent, fs.DirentDef);
if (err) {
console.log('dirent marshal failed: ' + err);
cb(-EFAULT);
return;
}
voff += len;
this.off++;
}
cb(voff);
});
示例2: sys_getsockname
function sys_getsockname(cb: Function, trap: number, arg0: any, arg1: any, arg2: any): void {
console.log('TODO: getsockname');
let view = new DataView(arg1.buffer, arg1.byteOffset);
Marshal(arg1, 0, {family: 2, port: 8080, addr: '127.0.0.1'}, socket.SockAddrInDef);
arg2.$set(socket.SockAddrInDef.length);
setTimeout(cb, 0, [0, 0, 0]);
}
示例3: function
let args = [arg0, function(err: any, fd: number, remoteAddr: string, remotePort: number): void {
if (remoteAddr === 'localhost')
remoteAddr = '127.0.0.1';
let view = new DataView($acceptArray.buffer, $acceptArray.byteOffset);
Marshal(view, 0, {family: 2, port: remotePort, addr: remoteAddr}, socket.SockAddrInDef);
$acceptLen.$set(socket.SockAddrInDef.length);
cb([err ? -1 : fd, 0, err ? -1 : 0]);
}];