github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/idltest/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/idltest", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "has_GetArrayBuffer": (): heap.Ref<boolean> => { 8 if (WEBEXT?.idltest && "getArrayBuffer" in WEBEXT?.idltest) { 9 return A.H.TRUE; 10 } 11 return A.H.FALSE; 12 }, 13 "func_GetArrayBuffer": (fn: Pointer): void => { 14 A.store.Ref(fn, WEBEXT.idltest.getArrayBuffer); 15 }, 16 "call_GetArrayBuffer": (retPtr: Pointer): void => { 17 const _ret = WEBEXT.idltest.getArrayBuffer(); 18 A.store.Ref(retPtr, _ret); 19 }, 20 "try_GetArrayBuffer": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 21 try { 22 const _ret = WEBEXT.idltest.getArrayBuffer(); 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 "has_NocompileFunc": (): heap.Ref<boolean> => { 31 if (WEBEXT?.idltest && "nocompileFunc" in WEBEXT?.idltest) { 32 return A.H.TRUE; 33 } 34 return A.H.FALSE; 35 }, 36 "func_NocompileFunc": (fn: Pointer): void => { 37 A.store.Ref(fn, WEBEXT.idltest.nocompileFunc); 38 }, 39 "call_NocompileFunc": (retPtr: Pointer, switch_: number): void => { 40 const _ret = WEBEXT.idltest.nocompileFunc(switch_); 41 }, 42 "try_NocompileFunc": (retPtr: Pointer, errPtr: Pointer, switch_: number): heap.Ref<boolean> => { 43 try { 44 const _ret = WEBEXT.idltest.nocompileFunc(switch_); 45 return A.H.TRUE; 46 } catch (err: any) { 47 A.store.Ref(errPtr, err); 48 return A.H.FALSE; 49 } 50 }, 51 "has_SendArrayBuffer": (): heap.Ref<boolean> => { 52 if (WEBEXT?.idltest && "sendArrayBuffer" in WEBEXT?.idltest) { 53 return A.H.TRUE; 54 } 55 return A.H.FALSE; 56 }, 57 "func_SendArrayBuffer": (fn: Pointer): void => { 58 A.store.Ref(fn, WEBEXT.idltest.sendArrayBuffer); 59 }, 60 "call_SendArrayBuffer": (retPtr: Pointer, input: heap.Ref<object>): void => { 61 const _ret = WEBEXT.idltest.sendArrayBuffer(A.H.get<object>(input)); 62 A.store.Ref(retPtr, _ret); 63 }, 64 "try_SendArrayBuffer": (retPtr: Pointer, errPtr: Pointer, input: heap.Ref<object>): heap.Ref<boolean> => { 65 try { 66 const _ret = WEBEXT.idltest.sendArrayBuffer(A.H.get<object>(input)); 67 A.store.Ref(retPtr, _ret); 68 return A.H.TRUE; 69 } catch (err: any) { 70 A.store.Ref(errPtr, err); 71 return A.H.FALSE; 72 } 73 }, 74 "has_SendArrayBufferView": (): heap.Ref<boolean> => { 75 if (WEBEXT?.idltest && "sendArrayBufferView" in WEBEXT?.idltest) { 76 return A.H.TRUE; 77 } 78 return A.H.FALSE; 79 }, 80 "func_SendArrayBufferView": (fn: Pointer): void => { 81 A.store.Ref(fn, WEBEXT.idltest.sendArrayBufferView); 82 }, 83 "call_SendArrayBufferView": (retPtr: Pointer, input: heap.Ref<object>): void => { 84 const _ret = WEBEXT.idltest.sendArrayBufferView(A.H.get<object>(input)); 85 A.store.Ref(retPtr, _ret); 86 }, 87 "try_SendArrayBufferView": (retPtr: Pointer, errPtr: Pointer, input: heap.Ref<object>): heap.Ref<boolean> => { 88 try { 89 const _ret = WEBEXT.idltest.sendArrayBufferView(A.H.get<object>(input)); 90 A.store.Ref(retPtr, _ret); 91 return A.H.TRUE; 92 } catch (err: any) { 93 A.store.Ref(errPtr, err); 94 return A.H.FALSE; 95 } 96 }, 97 }; 98 });