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

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/echoprivate", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "store_GetUserConsentArgConsentRequester": (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 + 17, false);
    12          A.store.Ref(ptr + 0, undefined);
    13          A.store.Ref(ptr + 4, undefined);
    14          A.store.Bool(ptr + 16, false);
    15          A.store.Int64(ptr + 8, 0);
    16        } else {
    17          A.store.Bool(ptr + 17, true);
    18          A.store.Ref(ptr + 0, x["origin"]);
    19          A.store.Ref(ptr + 4, x["serviceName"]);
    20          A.store.Bool(ptr + 16, "tabId" in x ? true : false);
    21          A.store.Int64(ptr + 8, x["tabId"] === undefined ? 0 : (x["tabId"] as number));
    22        }
    23      },
    24      "load_GetUserConsentArgConsentRequester": (
    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        x["origin"] = A.load.Ref(ptr + 0, undefined);
    32        x["serviceName"] = A.load.Ref(ptr + 4, undefined);
    33        if (A.load.Bool(ptr + 16)) {
    34          x["tabId"] = A.load.Int64(ptr + 8);
    35        } else {
    36          delete x["tabId"];
    37        }
    38        return create === A.H.TRUE ? A.H.push(x) : ref;
    39      },
    40      "has_GetOfferInfo": (): heap.Ref<boolean> => {
    41        if (WEBEXT?.echoPrivate && "getOfferInfo" in WEBEXT?.echoPrivate) {
    42          return A.H.TRUE;
    43        }
    44        return A.H.FALSE;
    45      },
    46      "func_GetOfferInfo": (fn: Pointer): void => {
    47        A.store.Ref(fn, WEBEXT.echoPrivate.getOfferInfo);
    48      },
    49      "call_GetOfferInfo": (retPtr: Pointer, id: heap.Ref<object>): void => {
    50        const _ret = WEBEXT.echoPrivate.getOfferInfo(A.H.get<object>(id));
    51        A.store.Ref(retPtr, _ret);
    52      },
    53      "try_GetOfferInfo": (retPtr: Pointer, errPtr: Pointer, id: heap.Ref<object>): heap.Ref<boolean> => {
    54        try {
    55          const _ret = WEBEXT.echoPrivate.getOfferInfo(A.H.get<object>(id));
    56          A.store.Ref(retPtr, _ret);
    57          return A.H.TRUE;
    58        } catch (err: any) {
    59          A.store.Ref(errPtr, err);
    60          return A.H.FALSE;
    61        }
    62      },
    63      "has_GetOobeTimestamp": (): heap.Ref<boolean> => {
    64        if (WEBEXT?.echoPrivate && "getOobeTimestamp" in WEBEXT?.echoPrivate) {
    65          return A.H.TRUE;
    66        }
    67        return A.H.FALSE;
    68      },
    69      "func_GetOobeTimestamp": (fn: Pointer): void => {
    70        A.store.Ref(fn, WEBEXT.echoPrivate.getOobeTimestamp);
    71      },
    72      "call_GetOobeTimestamp": (retPtr: Pointer): void => {
    73        const _ret = WEBEXT.echoPrivate.getOobeTimestamp();
    74        A.store.Ref(retPtr, _ret);
    75      },
    76      "try_GetOobeTimestamp": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
    77        try {
    78          const _ret = WEBEXT.echoPrivate.getOobeTimestamp();
    79          A.store.Ref(retPtr, _ret);
    80          return A.H.TRUE;
    81        } catch (err: any) {
    82          A.store.Ref(errPtr, err);
    83          return A.H.FALSE;
    84        }
    85      },
    86      "has_GetRegistrationCode": (): heap.Ref<boolean> => {
    87        if (WEBEXT?.echoPrivate && "getRegistrationCode" in WEBEXT?.echoPrivate) {
    88          return A.H.TRUE;
    89        }
    90        return A.H.FALSE;
    91      },
    92      "func_GetRegistrationCode": (fn: Pointer): void => {
    93        A.store.Ref(fn, WEBEXT.echoPrivate.getRegistrationCode);
    94      },
    95      "call_GetRegistrationCode": (retPtr: Pointer, type: heap.Ref<object>): void => {
    96        const _ret = WEBEXT.echoPrivate.getRegistrationCode(A.H.get<object>(type));
    97        A.store.Ref(retPtr, _ret);
    98      },
    99      "try_GetRegistrationCode": (retPtr: Pointer, errPtr: Pointer, type: heap.Ref<object>): heap.Ref<boolean> => {
   100        try {
   101          const _ret = WEBEXT.echoPrivate.getRegistrationCode(A.H.get<object>(type));
   102          A.store.Ref(retPtr, _ret);
   103          return A.H.TRUE;
   104        } catch (err: any) {
   105          A.store.Ref(errPtr, err);
   106          return A.H.FALSE;
   107        }
   108      },
   109      "has_GetUserConsent": (): heap.Ref<boolean> => {
   110        if (WEBEXT?.echoPrivate && "getUserConsent" in WEBEXT?.echoPrivate) {
   111          return A.H.TRUE;
   112        }
   113        return A.H.FALSE;
   114      },
   115      "func_GetUserConsent": (fn: Pointer): void => {
   116        A.store.Ref(fn, WEBEXT.echoPrivate.getUserConsent);
   117      },
   118      "call_GetUserConsent": (retPtr: Pointer, consentRequester: Pointer): void => {
   119        const consentRequester_ffi = {};
   120  
   121        consentRequester_ffi["origin"] = A.load.Ref(consentRequester + 0, undefined);
   122        consentRequester_ffi["serviceName"] = A.load.Ref(consentRequester + 4, undefined);
   123        if (A.load.Bool(consentRequester + 16)) {
   124          consentRequester_ffi["tabId"] = A.load.Int64(consentRequester + 8);
   125        }
   126  
   127        const _ret = WEBEXT.echoPrivate.getUserConsent(consentRequester_ffi);
   128        A.store.Ref(retPtr, _ret);
   129      },
   130      "try_GetUserConsent": (retPtr: Pointer, errPtr: Pointer, consentRequester: Pointer): heap.Ref<boolean> => {
   131        try {
   132          const consentRequester_ffi = {};
   133  
   134          consentRequester_ffi["origin"] = A.load.Ref(consentRequester + 0, undefined);
   135          consentRequester_ffi["serviceName"] = A.load.Ref(consentRequester + 4, undefined);
   136          if (A.load.Bool(consentRequester + 16)) {
   137            consentRequester_ffi["tabId"] = A.load.Int64(consentRequester + 8);
   138          }
   139  
   140          const _ret = WEBEXT.echoPrivate.getUserConsent(consentRequester_ffi);
   141          A.store.Ref(retPtr, _ret);
   142          return A.H.TRUE;
   143        } catch (err: any) {
   144          A.store.Ref(errPtr, err);
   145          return A.H.FALSE;
   146        }
   147      },
   148      "has_SetOfferInfo": (): heap.Ref<boolean> => {
   149        if (WEBEXT?.echoPrivate && "setOfferInfo" in WEBEXT?.echoPrivate) {
   150          return A.H.TRUE;
   151        }
   152        return A.H.FALSE;
   153      },
   154      "func_SetOfferInfo": (fn: Pointer): void => {
   155        A.store.Ref(fn, WEBEXT.echoPrivate.setOfferInfo);
   156      },
   157      "call_SetOfferInfo": (retPtr: Pointer, id: heap.Ref<object>, offerInfo: heap.Ref<object>): void => {
   158        const _ret = WEBEXT.echoPrivate.setOfferInfo(A.H.get<object>(id), A.H.get<object>(offerInfo));
   159      },
   160      "try_SetOfferInfo": (
   161        retPtr: Pointer,
   162        errPtr: Pointer,
   163        id: heap.Ref<object>,
   164        offerInfo: heap.Ref<object>
   165      ): heap.Ref<boolean> => {
   166        try {
   167          const _ret = WEBEXT.echoPrivate.setOfferInfo(A.H.get<object>(id), A.H.get<object>(offerInfo));
   168          return A.H.TRUE;
   169        } catch (err: any) {
   170          A.store.Ref(errPtr, err);
   171          return A.H.FALSE;
   172        }
   173      },
   174    };
   175  });