github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/commandlineprivate/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/commandlineprivate", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "has_HasSwitch": (): heap.Ref<boolean> => { 8 if (WEBEXT?.commandLinePrivate && "hasSwitch" in WEBEXT?.commandLinePrivate) { 9 return A.H.TRUE; 10 } 11 return A.H.FALSE; 12 }, 13 "func_HasSwitch": (fn: Pointer): void => { 14 A.store.Ref(fn, WEBEXT.commandLinePrivate.hasSwitch); 15 }, 16 "call_HasSwitch": (retPtr: Pointer, name: heap.Ref<object>): void => { 17 const _ret = WEBEXT.commandLinePrivate.hasSwitch(A.H.get<object>(name)); 18 A.store.Ref(retPtr, _ret); 19 }, 20 "try_HasSwitch": (retPtr: Pointer, errPtr: Pointer, name: heap.Ref<object>): heap.Ref<boolean> => { 21 try { 22 const _ret = WEBEXT.commandLinePrivate.hasSwitch(A.H.get<object>(name)); 23 A.store.Ref(retPtr, _ret); 24 return A.H.TRUE; 25 } catch (err: any) { 26 A.store.Ref(errPtr, err); 27 return A.H.FALSE; 28 } 29 }, 30 }; 31 });