github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/filehandlers/bindings/ffi_bindings.ts (about)

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/filehandlers", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "store_Icon": (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 + 12, false);
    12          A.store.Ref(ptr + 0, undefined);
    13          A.store.Ref(ptr + 4, undefined);
    14          A.store.Ref(ptr + 8, undefined);
    15        } else {
    16          A.store.Bool(ptr + 12, true);
    17          A.store.Ref(ptr + 0, x["src"]);
    18          A.store.Ref(ptr + 4, x["sizes"]);
    19          A.store.Ref(ptr + 8, x["type"]);
    20        }
    21      },
    22      "load_Icon": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    23        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    24  
    25        x["src"] = A.load.Ref(ptr + 0, undefined);
    26        x["sizes"] = A.load.Ref(ptr + 4, undefined);
    27        x["type"] = A.load.Ref(ptr + 8, undefined);
    28        return create === A.H.TRUE ? A.H.push(x) : ref;
    29      },
    30  
    31      "store_FileHandler": (ptr: Pointer, ref: heap.Ref<any>) => {
    32        const x = A.H.get<any>(ref);
    33  
    34        if (typeof x === "undefined") {
    35          A.store.Bool(ptr + 20, false);
    36          A.store.Ref(ptr + 0, undefined);
    37          A.store.Ref(ptr + 4, undefined);
    38          A.store.Ref(ptr + 8, undefined);
    39          A.store.Ref(ptr + 12, undefined);
    40          A.store.Ref(ptr + 16, undefined);
    41        } else {
    42          A.store.Bool(ptr + 20, true);
    43          A.store.Ref(ptr + 0, x["accept"]);
    44          A.store.Ref(ptr + 4, x["action"]);
    45          A.store.Ref(ptr + 8, x["name"]);
    46          A.store.Ref(ptr + 12, x["icons"]);
    47          A.store.Ref(ptr + 16, x["launch_type"]);
    48        }
    49      },
    50      "load_FileHandler": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    51        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    52  
    53        x["accept"] = A.load.Ref(ptr + 0, undefined);
    54        x["action"] = A.load.Ref(ptr + 4, undefined);
    55        x["name"] = A.load.Ref(ptr + 8, undefined);
    56        x["icons"] = A.load.Ref(ptr + 12, undefined);
    57        x["launch_type"] = A.load.Ref(ptr + 16, undefined);
    58        return create === A.H.TRUE ? A.H.push(x) : ref;
    59      },
    60  
    61      "store_ManifestKeys": (ptr: Pointer, ref: heap.Ref<any>) => {
    62        const x = A.H.get<any>(ref);
    63  
    64        if (typeof x === "undefined") {
    65          A.store.Bool(ptr + 4, false);
    66          A.store.Ref(ptr + 0, undefined);
    67        } else {
    68          A.store.Bool(ptr + 4, true);
    69          A.store.Ref(ptr + 0, x["file_handlers"]);
    70        }
    71      },
    72      "load_ManifestKeys": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    73        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    74  
    75        x["file_handlers"] = A.load.Ref(ptr + 0, undefined);
    76        return create === A.H.TRUE ? A.H.push(x) : ref;
    77      },
    78    };
    79  });