当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ffi.Callback函数代码示例

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


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

示例1: it

  it('success: A Logger Class can be cast to a C void pointer', () => {
    let count = 0
    const _logFn = (_level: number,
                    _target: string,
                    _message: string,
                    _modulePath: string,
                    _file: string,
                    _line: number) => {
      count = count + 1
      console.log('level: ' + _level)
      console.log('target: ' + _target)
      console.log('message: ' + _message)
      console.log('modulePath: ' + _modulePath)
      console.log('file: ' + _file)
      console.log('line: ' + _line)
    }
    const logFnCb = ffi.Callback('void', ['int', 'string', 'string', 'string', 'string', 'int'], _logFn)
    const logger = new Logger()
    logger.logFn = logFnCb
    const loggerPtr: any = loggerToVoidPtr(logger)

    const level = 123
    const target = 'target'
    const message = 'message'
    const modulePath = 'modulePath'
    const file = 'file'
    const line = 456

    loggerFunction(loggerPtr, level, target, message, modulePath, file, line)
  })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:30,代码来源:logging.2.test.ts

示例2: createInitCallback

export function createInitCallback(callback: Function)
{
	return ffi.Callback(
		ref.types.void
		, [GkeyCode, wchar_string, 'void *']
		, callback
	);
}
开发者ID:Zorbing,项目名称:node-lgsdk,代码行数:8,代码来源:ffi-lib.ts

示例3: reject

 (resolve, reject) => ffi.Callback('void', ['uint32', 'uint32', 'string'],
 (xcommandHandle: number, err: number, info: any) => {
   if (err) {
     reject(err)
     return
   }
   resolve(info)
 })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:8,代码来源:vcx-payment-txn.ts

示例4: Callback

 (resolve, reject) => Callback(
   'void',
   ['uint32','uint32'], (xhandle: number, err: number) => {
     if (err) {
       reject(err)
       return
     }
     resolve()
   })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:9,代码来源:wallet.ts

示例5: reject

 (resolve, reject) => ffi.Callback(
   'void',
   ['uint32', 'uint32', 'uint32'],
   (handle: number, err: number, state: StateType) => {
     if (err) {
       reject(err)
     }
     resolve(state)
   })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:9,代码来源:vcx-base-with-state.ts

示例6: reject

 (resolve, reject) => ffi.Callback(
   'void',
   ['uint32', 'uint32', 'uint32'],
   (xHandle: number, err: number, handle: number) => {
     if (err) {
       reject(err)
     }
     resolve(handle)
   })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:9,代码来源:vcx-base.ts

示例7: Callback

 (resolve, reject) => Callback(
   'void',
   ['uint32','uint32','string'],
   (xhandle: number, err: number, fees: string) => {
     if (err) {
       reject(err)
       return
     }
     resolve(fees)
   })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:10,代码来源:utils.ts

示例8: it

 it(`a call to vcx_connection_get_state should return ${VCXCode.INVALID_CONNECTION_HANDLE}`, () => {
   const result = run.ffi.vcx_connection_update_state(
     0,
     1,
     ffi.Callback(
       'void',
       ['uint32', 'uint32', 'uint32'],
       (xhandle: number, err: number, state: number) => null
     )
   )
   assert.equal(result, VCXCode.INVALID_CONNECTION_HANDLE)
 })
开发者ID:fabienpe,项目名称:indy-sdk,代码行数:12,代码来源:ffi.test.ts


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