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

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/extensionoptionsinternal", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "store_PreferredSizeChangedOptions": (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 + 18, false);
    12          A.store.Bool(ptr + 16, false);
    13          A.store.Float64(ptr + 0, 0);
    14          A.store.Bool(ptr + 17, false);
    15          A.store.Float64(ptr + 8, 0);
    16        } else {
    17          A.store.Bool(ptr + 18, true);
    18          A.store.Bool(ptr + 16, "width" in x ? true : false);
    19          A.store.Float64(ptr + 0, x["width"] === undefined ? 0 : (x["width"] as number));
    20          A.store.Bool(ptr + 17, "height" in x ? true : false);
    21          A.store.Float64(ptr + 8, x["height"] === undefined ? 0 : (x["height"] as number));
    22        }
    23      },
    24      "load_PreferredSizeChangedOptions": (
    25        ptr: Pointer,
    26        create: heap.Ref<boolean>,
    27        ref: heap.Ref<any>
    28      ): heap.Ref<any> => {
    29        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    30  
    31        if (A.load.Bool(ptr + 16)) {
    32          x["width"] = A.load.Float64(ptr + 0);
    33        } else {
    34          delete x["width"];
    35        }
    36        if (A.load.Bool(ptr + 17)) {
    37          x["height"] = A.load.Float64(ptr + 8);
    38        } else {
    39          delete x["height"];
    40        }
    41        return create === A.H.TRUE ? A.H.push(x) : ref;
    42      },
    43  
    44      "store_SizeChangedOptions": (ptr: Pointer, ref: heap.Ref<any>) => {
    45        const x = A.H.get<any>(ref);
    46  
    47        if (typeof x === "undefined") {
    48          A.store.Bool(ptr + 20, false);
    49          A.store.Bool(ptr + 16, false);
    50          A.store.Int32(ptr + 0, 0);
    51          A.store.Bool(ptr + 17, false);
    52          A.store.Int32(ptr + 4, 0);
    53          A.store.Bool(ptr + 18, false);
    54          A.store.Int32(ptr + 8, 0);
    55          A.store.Bool(ptr + 19, false);
    56          A.store.Int32(ptr + 12, 0);
    57        } else {
    58          A.store.Bool(ptr + 20, true);
    59          A.store.Bool(ptr + 16, "oldWidth" in x ? true : false);
    60          A.store.Int32(ptr + 0, x["oldWidth"] === undefined ? 0 : (x["oldWidth"] as number));
    61          A.store.Bool(ptr + 17, "oldHeight" in x ? true : false);
    62          A.store.Int32(ptr + 4, x["oldHeight"] === undefined ? 0 : (x["oldHeight"] as number));
    63          A.store.Bool(ptr + 18, "newWidth" in x ? true : false);
    64          A.store.Int32(ptr + 8, x["newWidth"] === undefined ? 0 : (x["newWidth"] as number));
    65          A.store.Bool(ptr + 19, "newHeight" in x ? true : false);
    66          A.store.Int32(ptr + 12, x["newHeight"] === undefined ? 0 : (x["newHeight"] as number));
    67        }
    68      },
    69      "load_SizeChangedOptions": (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 + 16)) {
    73          x["oldWidth"] = A.load.Int32(ptr + 0);
    74        } else {
    75          delete x["oldWidth"];
    76        }
    77        if (A.load.Bool(ptr + 17)) {
    78          x["oldHeight"] = A.load.Int32(ptr + 4);
    79        } else {
    80          delete x["oldHeight"];
    81        }
    82        if (A.load.Bool(ptr + 18)) {
    83          x["newWidth"] = A.load.Int32(ptr + 8);
    84        } else {
    85          delete x["newWidth"];
    86        }
    87        if (A.load.Bool(ptr + 19)) {
    88          x["newHeight"] = A.load.Int32(ptr + 12);
    89        } else {
    90          delete x["newHeight"];
    91        }
    92        return create === A.H.TRUE ? A.H.push(x) : ref;
    93      },
    94      "has_OnClose": (): heap.Ref<boolean> => {
    95        if (WEBEXT?.extensionOptionsInternal?.onClose && "addListener" in WEBEXT?.extensionOptionsInternal?.onClose) {
    96          return A.H.TRUE;
    97        }
    98        return A.H.FALSE;
    99      },
   100      "func_OnClose": (fn: Pointer): void => {
   101        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onClose.addListener);
   102      },
   103      "call_OnClose": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   104        const _ret = WEBEXT.extensionOptionsInternal.onClose.addListener(A.H.get<object>(callback));
   105      },
   106      "try_OnClose": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   107        try {
   108          const _ret = WEBEXT.extensionOptionsInternal.onClose.addListener(A.H.get<object>(callback));
   109          return A.H.TRUE;
   110        } catch (err: any) {
   111          A.store.Ref(errPtr, err);
   112          return A.H.FALSE;
   113        }
   114      },
   115      "has_OffClose": (): heap.Ref<boolean> => {
   116        if (WEBEXT?.extensionOptionsInternal?.onClose && "removeListener" in WEBEXT?.extensionOptionsInternal?.onClose) {
   117          return A.H.TRUE;
   118        }
   119        return A.H.FALSE;
   120      },
   121      "func_OffClose": (fn: Pointer): void => {
   122        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onClose.removeListener);
   123      },
   124      "call_OffClose": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   125        const _ret = WEBEXT.extensionOptionsInternal.onClose.removeListener(A.H.get<object>(callback));
   126      },
   127      "try_OffClose": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   128        try {
   129          const _ret = WEBEXT.extensionOptionsInternal.onClose.removeListener(A.H.get<object>(callback));
   130          return A.H.TRUE;
   131        } catch (err: any) {
   132          A.store.Ref(errPtr, err);
   133          return A.H.FALSE;
   134        }
   135      },
   136      "has_HasOnClose": (): heap.Ref<boolean> => {
   137        if (WEBEXT?.extensionOptionsInternal?.onClose && "hasListener" in WEBEXT?.extensionOptionsInternal?.onClose) {
   138          return A.H.TRUE;
   139        }
   140        return A.H.FALSE;
   141      },
   142      "func_HasOnClose": (fn: Pointer): void => {
   143        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onClose.hasListener);
   144      },
   145      "call_HasOnClose": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   146        const _ret = WEBEXT.extensionOptionsInternal.onClose.hasListener(A.H.get<object>(callback));
   147        A.store.Bool(retPtr, _ret);
   148      },
   149      "try_HasOnClose": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   150        try {
   151          const _ret = WEBEXT.extensionOptionsInternal.onClose.hasListener(A.H.get<object>(callback));
   152          A.store.Bool(retPtr, _ret);
   153          return A.H.TRUE;
   154        } catch (err: any) {
   155          A.store.Ref(errPtr, err);
   156          return A.H.FALSE;
   157        }
   158      },
   159      "has_OnLoad": (): heap.Ref<boolean> => {
   160        if (WEBEXT?.extensionOptionsInternal?.onLoad && "addListener" in WEBEXT?.extensionOptionsInternal?.onLoad) {
   161          return A.H.TRUE;
   162        }
   163        return A.H.FALSE;
   164      },
   165      "func_OnLoad": (fn: Pointer): void => {
   166        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onLoad.addListener);
   167      },
   168      "call_OnLoad": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   169        const _ret = WEBEXT.extensionOptionsInternal.onLoad.addListener(A.H.get<object>(callback));
   170      },
   171      "try_OnLoad": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   172        try {
   173          const _ret = WEBEXT.extensionOptionsInternal.onLoad.addListener(A.H.get<object>(callback));
   174          return A.H.TRUE;
   175        } catch (err: any) {
   176          A.store.Ref(errPtr, err);
   177          return A.H.FALSE;
   178        }
   179      },
   180      "has_OffLoad": (): heap.Ref<boolean> => {
   181        if (WEBEXT?.extensionOptionsInternal?.onLoad && "removeListener" in WEBEXT?.extensionOptionsInternal?.onLoad) {
   182          return A.H.TRUE;
   183        }
   184        return A.H.FALSE;
   185      },
   186      "func_OffLoad": (fn: Pointer): void => {
   187        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onLoad.removeListener);
   188      },
   189      "call_OffLoad": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   190        const _ret = WEBEXT.extensionOptionsInternal.onLoad.removeListener(A.H.get<object>(callback));
   191      },
   192      "try_OffLoad": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   193        try {
   194          const _ret = WEBEXT.extensionOptionsInternal.onLoad.removeListener(A.H.get<object>(callback));
   195          return A.H.TRUE;
   196        } catch (err: any) {
   197          A.store.Ref(errPtr, err);
   198          return A.H.FALSE;
   199        }
   200      },
   201      "has_HasOnLoad": (): heap.Ref<boolean> => {
   202        if (WEBEXT?.extensionOptionsInternal?.onLoad && "hasListener" in WEBEXT?.extensionOptionsInternal?.onLoad) {
   203          return A.H.TRUE;
   204        }
   205        return A.H.FALSE;
   206      },
   207      "func_HasOnLoad": (fn: Pointer): void => {
   208        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onLoad.hasListener);
   209      },
   210      "call_HasOnLoad": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   211        const _ret = WEBEXT.extensionOptionsInternal.onLoad.hasListener(A.H.get<object>(callback));
   212        A.store.Bool(retPtr, _ret);
   213      },
   214      "try_HasOnLoad": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   215        try {
   216          const _ret = WEBEXT.extensionOptionsInternal.onLoad.hasListener(A.H.get<object>(callback));
   217          A.store.Bool(retPtr, _ret);
   218          return A.H.TRUE;
   219        } catch (err: any) {
   220          A.store.Ref(errPtr, err);
   221          return A.H.FALSE;
   222        }
   223      },
   224      "has_OnPreferredSizeChanged": (): heap.Ref<boolean> => {
   225        if (
   226          WEBEXT?.extensionOptionsInternal?.onPreferredSizeChanged &&
   227          "addListener" in WEBEXT?.extensionOptionsInternal?.onPreferredSizeChanged
   228        ) {
   229          return A.H.TRUE;
   230        }
   231        return A.H.FALSE;
   232      },
   233      "func_OnPreferredSizeChanged": (fn: Pointer): void => {
   234        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.addListener);
   235      },
   236      "call_OnPreferredSizeChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   237        const _ret = WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.addListener(A.H.get<object>(callback));
   238      },
   239      "try_OnPreferredSizeChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   240        try {
   241          const _ret = WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.addListener(A.H.get<object>(callback));
   242          return A.H.TRUE;
   243        } catch (err: any) {
   244          A.store.Ref(errPtr, err);
   245          return A.H.FALSE;
   246        }
   247      },
   248      "has_OffPreferredSizeChanged": (): heap.Ref<boolean> => {
   249        if (
   250          WEBEXT?.extensionOptionsInternal?.onPreferredSizeChanged &&
   251          "removeListener" in WEBEXT?.extensionOptionsInternal?.onPreferredSizeChanged
   252        ) {
   253          return A.H.TRUE;
   254        }
   255        return A.H.FALSE;
   256      },
   257      "func_OffPreferredSizeChanged": (fn: Pointer): void => {
   258        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.removeListener);
   259      },
   260      "call_OffPreferredSizeChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   261        const _ret = WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.removeListener(A.H.get<object>(callback));
   262      },
   263      "try_OffPreferredSizeChanged": (
   264        retPtr: Pointer,
   265        errPtr: Pointer,
   266        callback: heap.Ref<object>
   267      ): heap.Ref<boolean> => {
   268        try {
   269          const _ret = WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.removeListener(A.H.get<object>(callback));
   270          return A.H.TRUE;
   271        } catch (err: any) {
   272          A.store.Ref(errPtr, err);
   273          return A.H.FALSE;
   274        }
   275      },
   276      "has_HasOnPreferredSizeChanged": (): heap.Ref<boolean> => {
   277        if (
   278          WEBEXT?.extensionOptionsInternal?.onPreferredSizeChanged &&
   279          "hasListener" in WEBEXT?.extensionOptionsInternal?.onPreferredSizeChanged
   280        ) {
   281          return A.H.TRUE;
   282        }
   283        return A.H.FALSE;
   284      },
   285      "func_HasOnPreferredSizeChanged": (fn: Pointer): void => {
   286        A.store.Ref(fn, WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.hasListener);
   287      },
   288      "call_HasOnPreferredSizeChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   289        const _ret = WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.hasListener(A.H.get<object>(callback));
   290        A.store.Bool(retPtr, _ret);
   291      },
   292      "try_HasOnPreferredSizeChanged": (
   293        retPtr: Pointer,
   294        errPtr: Pointer,
   295        callback: heap.Ref<object>
   296      ): heap.Ref<boolean> => {
   297        try {
   298          const _ret = WEBEXT.extensionOptionsInternal.onPreferredSizeChanged.hasListener(A.H.get<object>(callback));
   299          A.store.Bool(retPtr, _ret);
   300          return A.H.TRUE;
   301        } catch (err: any) {
   302          A.store.Ref(errPtr, err);
   303          return A.H.FALSE;
   304        }
   305      },
   306    };
   307  });