github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/webaccessibleresources/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/webaccessibleresources", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_WebAccessibleResource": (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 + 14, false); 12 A.store.Ref(ptr + 0, undefined); 13 A.store.Ref(ptr + 4, undefined); 14 A.store.Ref(ptr + 8, undefined); 15 A.store.Bool(ptr + 13, false); 16 A.store.Bool(ptr + 12, false); 17 } else { 18 A.store.Bool(ptr + 14, true); 19 A.store.Ref(ptr + 0, x["resources"]); 20 A.store.Ref(ptr + 4, x["matches"]); 21 A.store.Ref(ptr + 8, x["extension_ids"]); 22 A.store.Bool(ptr + 13, "use_dynamic_url" in x ? true : false); 23 A.store.Bool(ptr + 12, x["use_dynamic_url"] ? true : false); 24 } 25 }, 26 "load_WebAccessibleResource": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 27 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 28 29 x["resources"] = A.load.Ref(ptr + 0, undefined); 30 x["matches"] = A.load.Ref(ptr + 4, undefined); 31 x["extension_ids"] = A.load.Ref(ptr + 8, undefined); 32 if (A.load.Bool(ptr + 13)) { 33 x["use_dynamic_url"] = A.load.Bool(ptr + 12); 34 } else { 35 delete x["use_dynamic_url"]; 36 } 37 return create === A.H.TRUE ? A.H.push(x) : ref; 38 }, 39 40 "store_ManifestKeys": (ptr: Pointer, ref: heap.Ref<any>) => { 41 const x = A.H.get<any>(ref); 42 43 if (typeof x === "undefined") { 44 A.store.Bool(ptr + 4, false); 45 A.store.Ref(ptr + 0, undefined); 46 } else { 47 A.store.Bool(ptr + 4, true); 48 A.store.Ref(ptr + 0, x["web_accessible_resources"]); 49 } 50 }, 51 "load_ManifestKeys": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 52 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 53 54 x["web_accessible_resources"] = A.load.Ref(ptr + 0, undefined); 55 return create === A.H.TRUE ? A.H.push(x) : ref; 56 }, 57 }; 58 });