• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript flatbuffers.flatbuffers.Builder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中flatbuffers.flatbuffers.Builder的典型用法代码示例。如果您正苦于以下问题:TypeScript flatbuffers.Builder类的具体用法?TypeScript flatbuffers.Builder怎么用?TypeScript flatbuffers.Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了flatbuffers.Builder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: codeFetch

export function codeFetch(
  moduleSpecifier: string,
  containingFile: string
): ModuleInfo {
  util.log("os.ts codeFetch", moduleSpecifier, containingFile);
  // Send CodeFetch message
  const builder = new flatbuffers.Builder();
  const moduleSpecifier_ = builder.createString(moduleSpecifier);
  const containingFile_ = builder.createString(containingFile);
  fbs.CodeFetch.startCodeFetch(builder);
  fbs.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_);
  fbs.CodeFetch.addContainingFile(builder, containingFile_);
  const msg = fbs.CodeFetch.endCodeFetch(builder);
  fbs.Base.startBase(builder);
  fbs.Base.addMsg(builder, msg);
  fbs.Base.addMsgType(builder, fbs.Any.CodeFetch);
  builder.finish(fbs.Base.endBase(builder));
  const resBuf = deno.send(builder.asUint8Array());
  // Process CodeFetchRes
  const bb = new flatbuffers.ByteBuffer(new Uint8Array(resBuf));
  const baseRes = fbs.Base.getRootAsBase(bb);
  if (fbs.Any.NONE === baseRes.msgType()) {
    throw Error(baseRes.error());
  }
  assert(fbs.Any.CodeFetchRes === baseRes.msgType());
  const codeFetchRes = new fbs.CodeFetchRes();
  assert(baseRes.msg(codeFetchRes) != null);
  const r = {
    moduleName: codeFetchRes.moduleName(),
    filename: codeFetchRes.filename(),
    sourceCode: codeFetchRes.sourceCode(),
    outputCode: codeFetchRes.outputCode()
  };
  return r;
}
开发者ID:weizai118,项目名称:deno,代码行数:35,代码来源:os.ts


示例2: startMsg

function startMsg(cmdId: number): ArrayBuffer {
  const builder = new flatbuffers.Builder();
  const msg = fbs.Start.createStart(builder, 0);
  fbs.Base.startBase(builder);
  fbs.Base.addCmdId(builder, cmdId);
  fbs.Base.addMsg(builder, msg);
  fbs.Base.addMsgType(builder, fbs.Any.Start);
  builder.finish(fbs.Base.endBase(builder));
  return typedArrayToArrayBuffer(builder.asUint8Array());
}
开发者ID:amit242,项目名称:deno,代码行数:10,代码来源:main.ts


示例3: startMsg

function startMsg(cmdId: number): Uint8Array {
  const builder = new flatbuffers.Builder();
  fbs.Start.startStart(builder);
  const startOffset = fbs.Start.endStart(builder);
  fbs.Base.startBase(builder);
  fbs.Base.addCmdId(builder, cmdId);
  fbs.Base.addMsg(builder, startOffset);
  fbs.Base.addMsgType(builder, fbs.Any.Start);
  builder.finish(fbs.Base.endBase(builder));
  return builder.asUint8Array();
}
开发者ID:weizai118,项目名称:deno,代码行数:11,代码来源:main.ts


示例4: createSyntheticDictionaryIndexField

function createSyntheticDictionaryIndexField(field: Field, type: FieldType) {
    let layouts = [];
    let builder = new flatbuffers.Builder();
    if (field.nullable()) {
        VectorLayout.startVectorLayout(builder);
        VectorLayout.addBitWidth(builder, 8);
        VectorLayout.addType(builder, VectorType.VALIDITY);
        builder.finish(VectorLayout.endVectorLayout(builder));
        layouts.push(VectorLayout.getRootAsVectorLayout(builder.dataBuffer()));
        builder = new flatbuffers.Builder();
    }
    VectorLayout.startVectorLayout(builder);
    VectorLayout.addBitWidth(builder, type.bitWidth());
    VectorLayout.addType(builder, VectorType.DATA);
    builder.finish(VectorLayout.endVectorLayout(builder));
    layouts.push(VectorLayout.getRootAsVectorLayout(builder.dataBuffer()));
    return Object.create(field, {
        layout: { value(i) { return layouts[i]; } },
        layoutLength: { value() { return layouts.length; } }
    });
}
开发者ID:NonVolatileComputing,项目名称:arrow,代码行数:21,代码来源:vector.ts


示例5: codeCache

export function codeCache(
  filename: string,
  sourceCode: string,
  outputCode: string
): void {
  util.log("os.ts codeCache", filename, sourceCode, outputCode);
  const builder = new flatbuffers.Builder();
  const filename_ = builder.createString(filename);
  const sourceCode_ = builder.createString(sourceCode);
  const outputCode_ = builder.createString(outputCode);
  fbs.CodeCache.startCodeCache(builder);
  fbs.CodeCache.addFilename(builder, filename_);
  fbs.CodeCache.addSourceCode(builder, sourceCode_);
  fbs.CodeCache.addOutputCode(builder, outputCode_);
  const msg = fbs.CodeCache.endCodeCache(builder);
  fbs.Base.startBase(builder);
  fbs.Base.addMsg(builder, msg);
  fbs.Base.addMsgType(builder, fbs.Any.CodeCache);
  builder.finish(fbs.Base.endBase(builder));
  const resBuf = deno.send(builder.asUint8Array());
  // Expect null or error.
  if (resBuf != null) {
    const bb = new flatbuffers.ByteBuffer(new Uint8Array(resBuf));
    const baseRes = fbs.Base.getRootAsBase(bb);
    assert(fbs.Any.NONE === baseRes.msgType());
    throw Error(baseRes.error());
  }
}
开发者ID:weizai118,项目名称:deno,代码行数:28,代码来源:os.ts


示例6: codeCache

export function codeCache(
  filename: string,
  sourceCode: string,
  outputCode: string
): void {
  const builder = new flatbuffers.Builder();

  const filename_ = builder.createString(filename);
  const sourceCode_ = builder.createString(sourceCode);
  const outputCode_ = builder.createString(outputCode);

  fbs.CodeCache.startCodeCache(builder);
  fbs.CodeCache.addFilename(builder, filename_);
  fbs.CodeCache.addSourceCode(builder, sourceCode_);
  fbs.CodeCache.addOutputCode(builder, outputCode_);
  const msg = fbs.CodeCache.endCodeCache(builder);

  fbs.Base.startBase(builder);
  fbs.Base.addMsg(builder, msg);
  builder.finish(fbs.Base.endBase(builder));

  // Maybe need to do another step?
  // Base.finishBaseBuffer(builder, base);

  const payload = typedArrayToArrayBuffer(builder.asUint8Array());
  const resBuf = deno.send("x", payload);
  assert(resBuf === null);
}
开发者ID:amit242,项目名称:deno,代码行数:28,代码来源:os.ts


示例7: codeFetch

export function codeFetch(
  moduleSpecifier: string,
  containingFile: string
): ModuleInfo {
  console.log("Hello from codeFetch");

  // Send CodeFetch message
  const builder = new flatbuffers.Builder();
  const moduleSpecifier_ = builder.createString(moduleSpecifier);
  const containingFile_ = builder.createString(containingFile);
  fbs.CodeFetch.startCodeFetch(builder);
  fbs.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_);
  fbs.CodeFetch.addContainingFile(builder, containingFile_);
  const msg = fbs.CodeFetch.endCodeFetch(builder);
  fbs.Base.startBase(builder);
  fbs.Base.addMsg(builder, msg);
  fbs.Base.addMsgType(builder, fbs.Any.CodeFetch);
  builder.finish(fbs.Base.endBase(builder));
  const payload = typedArrayToArrayBuffer(builder.asUint8Array());
  const resBuf = deno.send("x", payload);

  console.log("CodeFetch sent");

  // Process CodeFetchRes
  const bb = new flatbuffers.ByteBuffer(new Uint8Array(resBuf));
  const baseRes = fbs.Base.getRootAsBase(bb);
  assert(fbs.Any.CodeFetchRes === baseRes.msgType());
  const codeFetchRes = new fbs.CodeFetchRes();
  assert(baseRes.msg(codeFetchRes) != null);
  return {
    moduleName: codeFetchRes.moduleName(),
    filename: codeFetchRes.filename(),
    sourceCode: codeFetchRes.sourceCode(),
    outputCode: codeFetchRes.outputCode()
  };
}
开发者ID:amit242,项目名称:deno,代码行数:36,代码来源:os.ts


示例8:

import {DOMBuffer} from './DOMBuffer.fbs'
import {flatbuffers} from 'flatbuffers'


var builder = new flatbuffers.Builder(1024)


DOMBuffer.ChangeText.startChangeText(builder)
DOMBuffer.ChangeText.addText(builder, builder.createString('Hello World'))
var node = DOMBuffer.ChangeText.endChangeText(builder)

DOMBuffer.Change.startChange(builder)
DOMBuffer.Change.addType(builder, DOMBuffer.ChangeType.Insert)
DOMBuffer.Change.addChange(builder, node)
var change = DOMBuffer.Change.endChange(builder)

builder.finish(change)
var bytes = builder.asUint8Array()

// Read

var buffer = new flatbuffers.ByteBuffer(bytes)
var diff = DOMBuffer.Change.getRootAsChange(buffer)
var changeType = diff.type()
var textNode = diff.change(new DOMBuffer.ChangeText)
开发者ID:Gozala,项目名称:dom-buffer,代码行数:25,代码来源:BufferStore.ts



注:本文中的flatbuffers.flatbuffers.Builder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fluent-ffmpeg.ffprobe函数代码示例发布时间:2022-05-25
下一篇:
TypeScript flat.unflatten函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap