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

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/chrome_url_overrides", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "store_UrlOverrideInfo": (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 + 20, 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.Ref(ptr + 12, undefined);
    16          A.store.Ref(ptr + 16, undefined);
    17        } else {
    18          A.store.Bool(ptr + 20, true);
    19          A.store.Ref(ptr + 0, x["newtab"]);
    20          A.store.Ref(ptr + 4, x["bookmarks"]);
    21          A.store.Ref(ptr + 8, x["history"]);
    22          A.store.Ref(ptr + 12, x["activationmessage"]);
    23          A.store.Ref(ptr + 16, x["keyboard"]);
    24        }
    25      },
    26      "load_UrlOverrideInfo": (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["newtab"] = A.load.Ref(ptr + 0, undefined);
    30        x["bookmarks"] = A.load.Ref(ptr + 4, undefined);
    31        x["history"] = A.load.Ref(ptr + 8, undefined);
    32        x["activationmessage"] = A.load.Ref(ptr + 12, undefined);
    33        x["keyboard"] = A.load.Ref(ptr + 16, undefined);
    34        return create === A.H.TRUE ? A.H.push(x) : ref;
    35      },
    36  
    37      "store_ManifestKeys": (ptr: Pointer, ref: heap.Ref<any>) => {
    38        const x = A.H.get<any>(ref);
    39  
    40        if (typeof x === "undefined") {
    41          A.store.Bool(ptr + 21, false);
    42  
    43          A.store.Bool(ptr + 0 + 20, false);
    44          A.store.Ref(ptr + 0 + 0, undefined);
    45          A.store.Ref(ptr + 0 + 4, undefined);
    46          A.store.Ref(ptr + 0 + 8, undefined);
    47          A.store.Ref(ptr + 0 + 12, undefined);
    48          A.store.Ref(ptr + 0 + 16, undefined);
    49        } else {
    50          A.store.Bool(ptr + 21, true);
    51  
    52          if (typeof x["chrome_url_overrides"] === "undefined") {
    53            A.store.Bool(ptr + 0 + 20, false);
    54            A.store.Ref(ptr + 0 + 0, undefined);
    55            A.store.Ref(ptr + 0 + 4, undefined);
    56            A.store.Ref(ptr + 0 + 8, undefined);
    57            A.store.Ref(ptr + 0 + 12, undefined);
    58            A.store.Ref(ptr + 0 + 16, undefined);
    59          } else {
    60            A.store.Bool(ptr + 0 + 20, true);
    61            A.store.Ref(ptr + 0 + 0, x["chrome_url_overrides"]["newtab"]);
    62            A.store.Ref(ptr + 0 + 4, x["chrome_url_overrides"]["bookmarks"]);
    63            A.store.Ref(ptr + 0 + 8, x["chrome_url_overrides"]["history"]);
    64            A.store.Ref(ptr + 0 + 12, x["chrome_url_overrides"]["activationmessage"]);
    65            A.store.Ref(ptr + 0 + 16, x["chrome_url_overrides"]["keyboard"]);
    66          }
    67        }
    68      },
    69      "load_ManifestKeys": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    70        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    71  
    72        if (A.load.Bool(ptr + 0 + 20)) {
    73          x["chrome_url_overrides"] = {};
    74          x["chrome_url_overrides"]["newtab"] = A.load.Ref(ptr + 0 + 0, undefined);
    75          x["chrome_url_overrides"]["bookmarks"] = A.load.Ref(ptr + 0 + 4, undefined);
    76          x["chrome_url_overrides"]["history"] = A.load.Ref(ptr + 0 + 8, undefined);
    77          x["chrome_url_overrides"]["activationmessage"] = A.load.Ref(ptr + 0 + 12, undefined);
    78          x["chrome_url_overrides"]["keyboard"] = A.load.Ref(ptr + 0 + 16, undefined);
    79        } else {
    80          delete x["chrome_url_overrides"];
    81        }
    82        return create === A.H.TRUE ? A.H.push(x) : ref;
    83      },
    84    };
    85  });