github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/systemlog/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/systemlog", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_MessageOptions": (ptr: Pointer, ref: heap.Ref<any>) => { 8 const x = A.H.get<any>(ref); 9 10 if (typeof x === "undefined") { 11 A.store.Bool(ptr + 4, false); 12 A.store.Ref(ptr + 0, undefined); 13 } else { 14 A.store.Bool(ptr + 4, true); 15 A.store.Ref(ptr + 0, x["message"]); 16 } 17 }, 18 "load_MessageOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 19 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 20 21 x["message"] = A.load.Ref(ptr + 0, undefined); 22 return create === A.H.TRUE ? A.H.push(x) : ref; 23 }, 24 "has_Add": (): heap.Ref<boolean> => { 25 if (WEBEXT?.systemLog && "add" in WEBEXT?.systemLog) { 26 return A.H.TRUE; 27 } 28 return A.H.FALSE; 29 }, 30 "func_Add": (fn: Pointer): void => { 31 A.store.Ref(fn, WEBEXT.systemLog.add); 32 }, 33 "call_Add": (retPtr: Pointer, options: Pointer): void => { 34 const options_ffi = {}; 35 36 options_ffi["message"] = A.load.Ref(options + 0, undefined); 37 38 const _ret = WEBEXT.systemLog.add(options_ffi); 39 A.store.Ref(retPtr, _ret); 40 }, 41 "try_Add": (retPtr: Pointer, errPtr: Pointer, options: Pointer): heap.Ref<boolean> => { 42 try { 43 const options_ffi = {}; 44 45 options_ffi["message"] = A.load.Ref(options + 0, undefined); 46 47 const _ret = WEBEXT.systemLog.add(options_ffi); 48 A.store.Ref(retPtr, _ret); 49 return A.H.TRUE; 50 } catch (err: any) { 51 A.store.Ref(errPtr, err); 52 return A.H.FALSE; 53 } 54 }, 55 }; 56 });