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

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/events", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "store_Rule": (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 + 29, 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 + 28, false);
    16          A.store.Int64(ptr + 16, 0);
    17          A.store.Ref(ptr + 24, undefined);
    18        } else {
    19          A.store.Bool(ptr + 29, true);
    20          A.store.Ref(ptr + 0, x["actions"]);
    21          A.store.Ref(ptr + 4, x["conditions"]);
    22          A.store.Ref(ptr + 8, x["id"]);
    23          A.store.Bool(ptr + 28, "priority" in x ? true : false);
    24          A.store.Int64(ptr + 16, x["priority"] === undefined ? 0 : (x["priority"] as number));
    25          A.store.Ref(ptr + 24, x["tags"]);
    26        }
    27      },
    28      "load_Rule": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    29        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    30  
    31        x["actions"] = A.load.Ref(ptr + 0, undefined);
    32        x["conditions"] = A.load.Ref(ptr + 4, undefined);
    33        x["id"] = A.load.Ref(ptr + 8, undefined);
    34        if (A.load.Bool(ptr + 28)) {
    35          x["priority"] = A.load.Int64(ptr + 16);
    36        } else {
    37          delete x["priority"];
    38        }
    39        x["tags"] = A.load.Ref(ptr + 24, undefined);
    40        return create === A.H.TRUE ? A.H.push(x) : ref;
    41      },
    42  
    43      "has_Event_AddListener": (self: heap.Ref<any>): heap.Ref<boolean> => {
    44        const obj = A.H.get<object>(self);
    45        if (obj && "addListener" in obj) {
    46          return A.H.TRUE;
    47        }
    48        return A.H.FALSE;
    49      },
    50      "func_Event_AddListener": (self: heap.Ref<any>, fn: Pointer): void => {
    51        A.store.Ref(fn, A.H.get<any>(self).addListener);
    52      },
    53  
    54      "call_Event_AddListener": (self: heap.Ref<object>, retPtr: Pointer, callback: heap.Ref<object>): void => {
    55        const thiz = A.H.get<any>(self);
    56  
    57        const _ret = thiz.addListener(A.H.get<object>(callback));
    58      },
    59      "try_Event_AddListener": (
    60        self: heap.Ref<object>,
    61        retPtr: Pointer,
    62        errPtr: Pointer,
    63        callback: heap.Ref<object>
    64      ): heap.Ref<boolean> => {
    65        try {
    66          const thiz = A.H.get<any>(self);
    67  
    68          const _ret = thiz.addListener(A.H.get<object>(callback));
    69          return A.H.TRUE;
    70        } catch (err: any) {
    71          A.store.Ref(errPtr, err);
    72          return A.H.FALSE;
    73        }
    74      },
    75      "has_Event_RemoveListener": (self: heap.Ref<any>): heap.Ref<boolean> => {
    76        const obj = A.H.get<object>(self);
    77        if (obj && "removeListener" in obj) {
    78          return A.H.TRUE;
    79        }
    80        return A.H.FALSE;
    81      },
    82      "func_Event_RemoveListener": (self: heap.Ref<any>, fn: Pointer): void => {
    83        A.store.Ref(fn, A.H.get<any>(self).removeListener);
    84      },
    85  
    86      "call_Event_RemoveListener": (self: heap.Ref<object>, retPtr: Pointer, callback: heap.Ref<object>): void => {
    87        const thiz = A.H.get<any>(self);
    88  
    89        const _ret = thiz.removeListener(A.H.get<object>(callback));
    90      },
    91      "try_Event_RemoveListener": (
    92        self: heap.Ref<object>,
    93        retPtr: Pointer,
    94        errPtr: Pointer,
    95        callback: heap.Ref<object>
    96      ): heap.Ref<boolean> => {
    97        try {
    98          const thiz = A.H.get<any>(self);
    99  
   100          const _ret = thiz.removeListener(A.H.get<object>(callback));
   101          return A.H.TRUE;
   102        } catch (err: any) {
   103          A.store.Ref(errPtr, err);
   104          return A.H.FALSE;
   105        }
   106      },
   107      "has_Event_HasListener": (self: heap.Ref<any>): heap.Ref<boolean> => {
   108        const obj = A.H.get<object>(self);
   109        if (obj && "hasListener" in obj) {
   110          return A.H.TRUE;
   111        }
   112        return A.H.FALSE;
   113      },
   114      "func_Event_HasListener": (self: heap.Ref<any>, fn: Pointer): void => {
   115        A.store.Ref(fn, A.H.get<any>(self).hasListener);
   116      },
   117  
   118      "call_Event_HasListener": (self: heap.Ref<object>, retPtr: Pointer, callback: heap.Ref<object>): void => {
   119        const thiz = A.H.get<any>(self);
   120  
   121        const _ret = thiz.hasListener(A.H.get<object>(callback));
   122        A.store.Bool(retPtr, _ret);
   123      },
   124      "try_Event_HasListener": (
   125        self: heap.Ref<object>,
   126        retPtr: Pointer,
   127        errPtr: Pointer,
   128        callback: heap.Ref<object>
   129      ): heap.Ref<boolean> => {
   130        try {
   131          const thiz = A.H.get<any>(self);
   132  
   133          const _ret = thiz.hasListener(A.H.get<object>(callback));
   134          A.store.Bool(retPtr, _ret);
   135          return A.H.TRUE;
   136        } catch (err: any) {
   137          A.store.Ref(errPtr, err);
   138          return A.H.FALSE;
   139        }
   140      },
   141      "has_Event_HasListeners": (self: heap.Ref<any>): heap.Ref<boolean> => {
   142        const obj = A.H.get<object>(self);
   143        if (obj && "hasListeners" in obj) {
   144          return A.H.TRUE;
   145        }
   146        return A.H.FALSE;
   147      },
   148      "func_Event_HasListeners": (self: heap.Ref<any>, fn: Pointer): void => {
   149        A.store.Ref(fn, A.H.get<any>(self).hasListeners);
   150      },
   151  
   152      "call_Event_HasListeners": (self: heap.Ref<object>, retPtr: Pointer): void => {
   153        const thiz = A.H.get<any>(self);
   154  
   155        const _ret = thiz.hasListeners();
   156        A.store.Bool(retPtr, _ret);
   157      },
   158      "try_Event_HasListeners": (self: heap.Ref<object>, retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   159        try {
   160          const thiz = A.H.get<any>(self);
   161  
   162          const _ret = thiz.hasListeners();
   163          A.store.Bool(retPtr, _ret);
   164          return A.H.TRUE;
   165        } catch (err: any) {
   166          A.store.Ref(errPtr, err);
   167          return A.H.FALSE;
   168        }
   169      },
   170      "has_Event_AddRules": (self: heap.Ref<any>): heap.Ref<boolean> => {
   171        const obj = A.H.get<object>(self);
   172        if (obj && "addRules" in obj) {
   173          return A.H.TRUE;
   174        }
   175        return A.H.FALSE;
   176      },
   177      "func_Event_AddRules": (self: heap.Ref<any>, fn: Pointer): void => {
   178        A.store.Ref(fn, A.H.get<any>(self).addRules);
   179      },
   180  
   181      "call_Event_AddRules": (
   182        self: heap.Ref<object>,
   183        retPtr: Pointer,
   184        eventName: heap.Ref<object>,
   185        webViewInstanceId: number,
   186        rules: heap.Ref<object>,
   187        callback: heap.Ref<object>
   188      ): void => {
   189        const thiz = A.H.get<any>(self);
   190  
   191        const _ret = thiz.addRules(
   192          A.H.get<object>(eventName),
   193          webViewInstanceId,
   194          A.H.get<object>(rules),
   195          A.H.get<object>(callback)
   196        );
   197      },
   198      "try_Event_AddRules": (
   199        self: heap.Ref<object>,
   200        retPtr: Pointer,
   201        errPtr: Pointer,
   202        eventName: heap.Ref<object>,
   203        webViewInstanceId: number,
   204        rules: heap.Ref<object>,
   205        callback: heap.Ref<object>
   206      ): heap.Ref<boolean> => {
   207        try {
   208          const thiz = A.H.get<any>(self);
   209  
   210          const _ret = thiz.addRules(
   211            A.H.get<object>(eventName),
   212            webViewInstanceId,
   213            A.H.get<object>(rules),
   214            A.H.get<object>(callback)
   215          );
   216          return A.H.TRUE;
   217        } catch (err: any) {
   218          A.store.Ref(errPtr, err);
   219          return A.H.FALSE;
   220        }
   221      },
   222      "has_Event_AddRules1": (self: heap.Ref<any>): heap.Ref<boolean> => {
   223        const obj = A.H.get<object>(self);
   224        if (obj && "addRules" in obj) {
   225          return A.H.TRUE;
   226        }
   227        return A.H.FALSE;
   228      },
   229      "func_Event_AddRules1": (self: heap.Ref<any>, fn: Pointer): void => {
   230        A.store.Ref(fn, A.H.get<any>(self).addRules);
   231      },
   232  
   233      "call_Event_AddRules1": (
   234        self: heap.Ref<object>,
   235        retPtr: Pointer,
   236        eventName: heap.Ref<object>,
   237        webViewInstanceId: number,
   238        rules: heap.Ref<object>
   239      ): void => {
   240        const thiz = A.H.get<any>(self);
   241  
   242        const _ret = thiz.addRules(A.H.get<object>(eventName), webViewInstanceId, A.H.get<object>(rules));
   243      },
   244      "try_Event_AddRules1": (
   245        self: heap.Ref<object>,
   246        retPtr: Pointer,
   247        errPtr: Pointer,
   248        eventName: heap.Ref<object>,
   249        webViewInstanceId: number,
   250        rules: heap.Ref<object>
   251      ): heap.Ref<boolean> => {
   252        try {
   253          const thiz = A.H.get<any>(self);
   254  
   255          const _ret = thiz.addRules(A.H.get<object>(eventName), webViewInstanceId, A.H.get<object>(rules));
   256          return A.H.TRUE;
   257        } catch (err: any) {
   258          A.store.Ref(errPtr, err);
   259          return A.H.FALSE;
   260        }
   261      },
   262      "has_Event_GetRules": (self: heap.Ref<any>): heap.Ref<boolean> => {
   263        const obj = A.H.get<object>(self);
   264        if (obj && "getRules" in obj) {
   265          return A.H.TRUE;
   266        }
   267        return A.H.FALSE;
   268      },
   269      "func_Event_GetRules": (self: heap.Ref<any>, fn: Pointer): void => {
   270        A.store.Ref(fn, A.H.get<any>(self).getRules);
   271      },
   272  
   273      "call_Event_GetRules": (
   274        self: heap.Ref<object>,
   275        retPtr: Pointer,
   276        eventName: heap.Ref<object>,
   277        webViewInstanceId: number,
   278        ruleIdentifiers: heap.Ref<object>,
   279        callback: heap.Ref<object>
   280      ): void => {
   281        const thiz = A.H.get<any>(self);
   282  
   283        const _ret = thiz.getRules(
   284          A.H.get<object>(eventName),
   285          webViewInstanceId,
   286          A.H.get<object>(ruleIdentifiers),
   287          A.H.get<object>(callback)
   288        );
   289      },
   290      "try_Event_GetRules": (
   291        self: heap.Ref<object>,
   292        retPtr: Pointer,
   293        errPtr: Pointer,
   294        eventName: heap.Ref<object>,
   295        webViewInstanceId: number,
   296        ruleIdentifiers: heap.Ref<object>,
   297        callback: heap.Ref<object>
   298      ): heap.Ref<boolean> => {
   299        try {
   300          const thiz = A.H.get<any>(self);
   301  
   302          const _ret = thiz.getRules(
   303            A.H.get<object>(eventName),
   304            webViewInstanceId,
   305            A.H.get<object>(ruleIdentifiers),
   306            A.H.get<object>(callback)
   307          );
   308          return A.H.TRUE;
   309        } catch (err: any) {
   310          A.store.Ref(errPtr, err);
   311          return A.H.FALSE;
   312        }
   313      },
   314      "has_Event_GetRules1": (self: heap.Ref<any>): heap.Ref<boolean> => {
   315        const obj = A.H.get<object>(self);
   316        if (obj && "getRules" in obj) {
   317          return A.H.TRUE;
   318        }
   319        return A.H.FALSE;
   320      },
   321      "func_Event_GetRules1": (self: heap.Ref<any>, fn: Pointer): void => {
   322        A.store.Ref(fn, A.H.get<any>(self).getRules);
   323      },
   324  
   325      "call_Event_GetRules1": (
   326        self: heap.Ref<object>,
   327        retPtr: Pointer,
   328        eventName: heap.Ref<object>,
   329        webViewInstanceId: number
   330      ): void => {
   331        const thiz = A.H.get<any>(self);
   332  
   333        const _ret = thiz.getRules(A.H.get<object>(eventName), webViewInstanceId);
   334      },
   335      "try_Event_GetRules1": (
   336        self: heap.Ref<object>,
   337        retPtr: Pointer,
   338        errPtr: Pointer,
   339        eventName: heap.Ref<object>,
   340        webViewInstanceId: number
   341      ): heap.Ref<boolean> => {
   342        try {
   343          const thiz = A.H.get<any>(self);
   344  
   345          const _ret = thiz.getRules(A.H.get<object>(eventName), webViewInstanceId);
   346          return A.H.TRUE;
   347        } catch (err: any) {
   348          A.store.Ref(errPtr, err);
   349          return A.H.FALSE;
   350        }
   351      },
   352      "has_Event_RemoveRules": (self: heap.Ref<any>): heap.Ref<boolean> => {
   353        const obj = A.H.get<object>(self);
   354        if (obj && "removeRules" in obj) {
   355          return A.H.TRUE;
   356        }
   357        return A.H.FALSE;
   358      },
   359      "func_Event_RemoveRules": (self: heap.Ref<any>, fn: Pointer): void => {
   360        A.store.Ref(fn, A.H.get<any>(self).removeRules);
   361      },
   362  
   363      "call_Event_RemoveRules": (
   364        self: heap.Ref<object>,
   365        retPtr: Pointer,
   366        eventName: heap.Ref<object>,
   367        webViewInstanceId: number,
   368        ruleIdentifiers: heap.Ref<object>,
   369        callback: heap.Ref<object>
   370      ): void => {
   371        const thiz = A.H.get<any>(self);
   372  
   373        const _ret = thiz.removeRules(
   374          A.H.get<object>(eventName),
   375          webViewInstanceId,
   376          A.H.get<object>(ruleIdentifiers),
   377          A.H.get<object>(callback)
   378        );
   379      },
   380      "try_Event_RemoveRules": (
   381        self: heap.Ref<object>,
   382        retPtr: Pointer,
   383        errPtr: Pointer,
   384        eventName: heap.Ref<object>,
   385        webViewInstanceId: number,
   386        ruleIdentifiers: heap.Ref<object>,
   387        callback: heap.Ref<object>
   388      ): heap.Ref<boolean> => {
   389        try {
   390          const thiz = A.H.get<any>(self);
   391  
   392          const _ret = thiz.removeRules(
   393            A.H.get<object>(eventName),
   394            webViewInstanceId,
   395            A.H.get<object>(ruleIdentifiers),
   396            A.H.get<object>(callback)
   397          );
   398          return A.H.TRUE;
   399        } catch (err: any) {
   400          A.store.Ref(errPtr, err);
   401          return A.H.FALSE;
   402        }
   403      },
   404      "has_Event_RemoveRules1": (self: heap.Ref<any>): heap.Ref<boolean> => {
   405        const obj = A.H.get<object>(self);
   406        if (obj && "removeRules" in obj) {
   407          return A.H.TRUE;
   408        }
   409        return A.H.FALSE;
   410      },
   411      "func_Event_RemoveRules1": (self: heap.Ref<any>, fn: Pointer): void => {
   412        A.store.Ref(fn, A.H.get<any>(self).removeRules);
   413      },
   414  
   415      "call_Event_RemoveRules1": (
   416        self: heap.Ref<object>,
   417        retPtr: Pointer,
   418        eventName: heap.Ref<object>,
   419        webViewInstanceId: number,
   420        ruleIdentifiers: heap.Ref<object>
   421      ): void => {
   422        const thiz = A.H.get<any>(self);
   423  
   424        const _ret = thiz.removeRules(A.H.get<object>(eventName), webViewInstanceId, A.H.get<object>(ruleIdentifiers));
   425      },
   426      "try_Event_RemoveRules1": (
   427        self: heap.Ref<object>,
   428        retPtr: Pointer,
   429        errPtr: Pointer,
   430        eventName: heap.Ref<object>,
   431        webViewInstanceId: number,
   432        ruleIdentifiers: heap.Ref<object>
   433      ): heap.Ref<boolean> => {
   434        try {
   435          const thiz = A.H.get<any>(self);
   436  
   437          const _ret = thiz.removeRules(A.H.get<object>(eventName), webViewInstanceId, A.H.get<object>(ruleIdentifiers));
   438          return A.H.TRUE;
   439        } catch (err: any) {
   440          A.store.Ref(errPtr, err);
   441          return A.H.FALSE;
   442        }
   443      },
   444      "has_Event_RemoveRules2": (self: heap.Ref<any>): heap.Ref<boolean> => {
   445        const obj = A.H.get<object>(self);
   446        if (obj && "removeRules" in obj) {
   447          return A.H.TRUE;
   448        }
   449        return A.H.FALSE;
   450      },
   451      "func_Event_RemoveRules2": (self: heap.Ref<any>, fn: Pointer): void => {
   452        A.store.Ref(fn, A.H.get<any>(self).removeRules);
   453      },
   454  
   455      "call_Event_RemoveRules2": (
   456        self: heap.Ref<object>,
   457        retPtr: Pointer,
   458        eventName: heap.Ref<object>,
   459        webViewInstanceId: number
   460      ): void => {
   461        const thiz = A.H.get<any>(self);
   462  
   463        const _ret = thiz.removeRules(A.H.get<object>(eventName), webViewInstanceId);
   464      },
   465      "try_Event_RemoveRules2": (
   466        self: heap.Ref<object>,
   467        retPtr: Pointer,
   468        errPtr: Pointer,
   469        eventName: heap.Ref<object>,
   470        webViewInstanceId: number
   471      ): heap.Ref<boolean> => {
   472        try {
   473          const thiz = A.H.get<any>(self);
   474  
   475          const _ret = thiz.removeRules(A.H.get<object>(eventName), webViewInstanceId);
   476          return A.H.TRUE;
   477        } catch (err: any) {
   478          A.store.Ref(errPtr, err);
   479          return A.H.FALSE;
   480        }
   481      },
   482  
   483      "store_UrlFilter": (ptr: Pointer, ref: heap.Ref<any>) => {
   484        const x = A.H.get<any>(ref);
   485  
   486        if (typeof x === "undefined") {
   487          A.store.Bool(ptr + 80, false);
   488          A.store.Ref(ptr + 0, undefined);
   489          A.store.Ref(ptr + 4, undefined);
   490          A.store.Ref(ptr + 8, undefined);
   491          A.store.Ref(ptr + 12, undefined);
   492          A.store.Ref(ptr + 16, undefined);
   493          A.store.Ref(ptr + 20, undefined);
   494          A.store.Ref(ptr + 24, undefined);
   495          A.store.Ref(ptr + 28, undefined);
   496          A.store.Ref(ptr + 32, undefined);
   497          A.store.Ref(ptr + 36, undefined);
   498          A.store.Ref(ptr + 40, undefined);
   499          A.store.Ref(ptr + 44, undefined);
   500          A.store.Ref(ptr + 48, undefined);
   501          A.store.Ref(ptr + 52, undefined);
   502          A.store.Ref(ptr + 56, undefined);
   503          A.store.Ref(ptr + 60, undefined);
   504          A.store.Ref(ptr + 64, undefined);
   505          A.store.Ref(ptr + 68, undefined);
   506          A.store.Ref(ptr + 72, undefined);
   507          A.store.Ref(ptr + 76, undefined);
   508        } else {
   509          A.store.Bool(ptr + 80, true);
   510          A.store.Ref(ptr + 0, x["hostContains"]);
   511          A.store.Ref(ptr + 4, x["hostEquals"]);
   512          A.store.Ref(ptr + 8, x["hostPrefix"]);
   513          A.store.Ref(ptr + 12, x["hostSuffix"]);
   514          A.store.Ref(ptr + 16, x["originAndPathMatches"]);
   515          A.store.Ref(ptr + 20, x["pathContains"]);
   516          A.store.Ref(ptr + 24, x["pathEquals"]);
   517          A.store.Ref(ptr + 28, x["pathPrefix"]);
   518          A.store.Ref(ptr + 32, x["pathSuffix"]);
   519          A.store.Ref(ptr + 36, x["ports"]);
   520          A.store.Ref(ptr + 40, x["queryContains"]);
   521          A.store.Ref(ptr + 44, x["queryEquals"]);
   522          A.store.Ref(ptr + 48, x["queryPrefix"]);
   523          A.store.Ref(ptr + 52, x["querySuffix"]);
   524          A.store.Ref(ptr + 56, x["schemes"]);
   525          A.store.Ref(ptr + 60, x["urlContains"]);
   526          A.store.Ref(ptr + 64, x["urlEquals"]);
   527          A.store.Ref(ptr + 68, x["urlMatches"]);
   528          A.store.Ref(ptr + 72, x["urlPrefix"]);
   529          A.store.Ref(ptr + 76, x["urlSuffix"]);
   530        }
   531      },
   532      "load_UrlFilter": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
   533        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
   534  
   535        x["hostContains"] = A.load.Ref(ptr + 0, undefined);
   536        x["hostEquals"] = A.load.Ref(ptr + 4, undefined);
   537        x["hostPrefix"] = A.load.Ref(ptr + 8, undefined);
   538        x["hostSuffix"] = A.load.Ref(ptr + 12, undefined);
   539        x["originAndPathMatches"] = A.load.Ref(ptr + 16, undefined);
   540        x["pathContains"] = A.load.Ref(ptr + 20, undefined);
   541        x["pathEquals"] = A.load.Ref(ptr + 24, undefined);
   542        x["pathPrefix"] = A.load.Ref(ptr + 28, undefined);
   543        x["pathSuffix"] = A.load.Ref(ptr + 32, undefined);
   544        x["ports"] = A.load.Ref(ptr + 36, undefined);
   545        x["queryContains"] = A.load.Ref(ptr + 40, undefined);
   546        x["queryEquals"] = A.load.Ref(ptr + 44, undefined);
   547        x["queryPrefix"] = A.load.Ref(ptr + 48, undefined);
   548        x["querySuffix"] = A.load.Ref(ptr + 52, undefined);
   549        x["schemes"] = A.load.Ref(ptr + 56, undefined);
   550        x["urlContains"] = A.load.Ref(ptr + 60, undefined);
   551        x["urlEquals"] = A.load.Ref(ptr + 64, undefined);
   552        x["urlMatches"] = A.load.Ref(ptr + 68, undefined);
   553        x["urlPrefix"] = A.load.Ref(ptr + 72, undefined);
   554        x["urlSuffix"] = A.load.Ref(ptr + 76, undefined);
   555        return create === A.H.TRUE ? A.H.push(x) : ref;
   556      },
   557    };
   558  });