github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/readinglist/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/readinglist", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_AddEntryOptions": (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 + 10, false); 12 A.store.Ref(ptr + 0, undefined); 13 A.store.Ref(ptr + 4, undefined); 14 A.store.Bool(ptr + 9, false); 15 A.store.Bool(ptr + 8, false); 16 } else { 17 A.store.Bool(ptr + 10, true); 18 A.store.Ref(ptr + 0, x["url"]); 19 A.store.Ref(ptr + 4, x["title"]); 20 A.store.Bool(ptr + 9, "hasBeenRead" in x ? true : false); 21 A.store.Bool(ptr + 8, x["hasBeenRead"] ? true : false); 22 } 23 }, 24 "load_AddEntryOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 25 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 26 27 x["url"] = A.load.Ref(ptr + 0, undefined); 28 x["title"] = A.load.Ref(ptr + 4, undefined); 29 if (A.load.Bool(ptr + 9)) { 30 x["hasBeenRead"] = A.load.Bool(ptr + 8); 31 } else { 32 delete x["hasBeenRead"]; 33 } 34 return create === A.H.TRUE ? A.H.push(x) : ref; 35 }, 36 37 "store_ReadingListEntry": (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 + 35, false); 42 A.store.Ref(ptr + 0, undefined); 43 A.store.Ref(ptr + 4, undefined); 44 A.store.Bool(ptr + 32, false); 45 A.store.Bool(ptr + 8, false); 46 A.store.Bool(ptr + 33, false); 47 A.store.Float64(ptr + 16, 0); 48 A.store.Bool(ptr + 34, false); 49 A.store.Float64(ptr + 24, 0); 50 } else { 51 A.store.Bool(ptr + 35, true); 52 A.store.Ref(ptr + 0, x["url"]); 53 A.store.Ref(ptr + 4, x["title"]); 54 A.store.Bool(ptr + 32, "hasBeenRead" in x ? true : false); 55 A.store.Bool(ptr + 8, x["hasBeenRead"] ? true : false); 56 A.store.Bool(ptr + 33, "lastUpdateTime" in x ? true : false); 57 A.store.Float64(ptr + 16, x["lastUpdateTime"] === undefined ? 0 : (x["lastUpdateTime"] as number)); 58 A.store.Bool(ptr + 34, "creationTime" in x ? true : false); 59 A.store.Float64(ptr + 24, x["creationTime"] === undefined ? 0 : (x["creationTime"] as number)); 60 } 61 }, 62 "load_ReadingListEntry": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 63 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 64 65 x["url"] = A.load.Ref(ptr + 0, undefined); 66 x["title"] = A.load.Ref(ptr + 4, undefined); 67 if (A.load.Bool(ptr + 32)) { 68 x["hasBeenRead"] = A.load.Bool(ptr + 8); 69 } else { 70 delete x["hasBeenRead"]; 71 } 72 if (A.load.Bool(ptr + 33)) { 73 x["lastUpdateTime"] = A.load.Float64(ptr + 16); 74 } else { 75 delete x["lastUpdateTime"]; 76 } 77 if (A.load.Bool(ptr + 34)) { 78 x["creationTime"] = A.load.Float64(ptr + 24); 79 } else { 80 delete x["creationTime"]; 81 } 82 return create === A.H.TRUE ? A.H.push(x) : ref; 83 }, 84 85 "store_QueryInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 86 const x = A.H.get<any>(ref); 87 88 if (typeof x === "undefined") { 89 A.store.Bool(ptr + 10, false); 90 A.store.Ref(ptr + 0, undefined); 91 A.store.Ref(ptr + 4, undefined); 92 A.store.Bool(ptr + 9, false); 93 A.store.Bool(ptr + 8, false); 94 } else { 95 A.store.Bool(ptr + 10, true); 96 A.store.Ref(ptr + 0, x["url"]); 97 A.store.Ref(ptr + 4, x["title"]); 98 A.store.Bool(ptr + 9, "hasBeenRead" in x ? true : false); 99 A.store.Bool(ptr + 8, x["hasBeenRead"] ? true : false); 100 } 101 }, 102 "load_QueryInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 103 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 104 105 x["url"] = A.load.Ref(ptr + 0, undefined); 106 x["title"] = A.load.Ref(ptr + 4, undefined); 107 if (A.load.Bool(ptr + 9)) { 108 x["hasBeenRead"] = A.load.Bool(ptr + 8); 109 } else { 110 delete x["hasBeenRead"]; 111 } 112 return create === A.H.TRUE ? A.H.push(x) : ref; 113 }, 114 115 "store_RemoveOptions": (ptr: Pointer, ref: heap.Ref<any>) => { 116 const x = A.H.get<any>(ref); 117 118 if (typeof x === "undefined") { 119 A.store.Bool(ptr + 4, false); 120 A.store.Ref(ptr + 0, undefined); 121 } else { 122 A.store.Bool(ptr + 4, true); 123 A.store.Ref(ptr + 0, x["url"]); 124 } 125 }, 126 "load_RemoveOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 127 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 128 129 x["url"] = A.load.Ref(ptr + 0, undefined); 130 return create === A.H.TRUE ? A.H.push(x) : ref; 131 }, 132 133 "store_UpdateEntryOptions": (ptr: Pointer, ref: heap.Ref<any>) => { 134 const x = A.H.get<any>(ref); 135 136 if (typeof x === "undefined") { 137 A.store.Bool(ptr + 10, false); 138 A.store.Ref(ptr + 0, undefined); 139 A.store.Ref(ptr + 4, undefined); 140 A.store.Bool(ptr + 9, false); 141 A.store.Bool(ptr + 8, false); 142 } else { 143 A.store.Bool(ptr + 10, true); 144 A.store.Ref(ptr + 0, x["url"]); 145 A.store.Ref(ptr + 4, x["title"]); 146 A.store.Bool(ptr + 9, "hasBeenRead" in x ? true : false); 147 A.store.Bool(ptr + 8, x["hasBeenRead"] ? true : false); 148 } 149 }, 150 "load_UpdateEntryOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 151 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 152 153 x["url"] = A.load.Ref(ptr + 0, undefined); 154 x["title"] = A.load.Ref(ptr + 4, undefined); 155 if (A.load.Bool(ptr + 9)) { 156 x["hasBeenRead"] = A.load.Bool(ptr + 8); 157 } else { 158 delete x["hasBeenRead"]; 159 } 160 return create === A.H.TRUE ? A.H.push(x) : ref; 161 }, 162 "has_AddEntry": (): heap.Ref<boolean> => { 163 if (WEBEXT?.readingList && "addEntry" in WEBEXT?.readingList) { 164 return A.H.TRUE; 165 } 166 return A.H.FALSE; 167 }, 168 "func_AddEntry": (fn: Pointer): void => { 169 A.store.Ref(fn, WEBEXT.readingList.addEntry); 170 }, 171 "call_AddEntry": (retPtr: Pointer, entry: Pointer): void => { 172 const entry_ffi = {}; 173 174 entry_ffi["url"] = A.load.Ref(entry + 0, undefined); 175 entry_ffi["title"] = A.load.Ref(entry + 4, undefined); 176 if (A.load.Bool(entry + 9)) { 177 entry_ffi["hasBeenRead"] = A.load.Bool(entry + 8); 178 } 179 180 const _ret = WEBEXT.readingList.addEntry(entry_ffi); 181 A.store.Ref(retPtr, _ret); 182 }, 183 "try_AddEntry": (retPtr: Pointer, errPtr: Pointer, entry: Pointer): heap.Ref<boolean> => { 184 try { 185 const entry_ffi = {}; 186 187 entry_ffi["url"] = A.load.Ref(entry + 0, undefined); 188 entry_ffi["title"] = A.load.Ref(entry + 4, undefined); 189 if (A.load.Bool(entry + 9)) { 190 entry_ffi["hasBeenRead"] = A.load.Bool(entry + 8); 191 } 192 193 const _ret = WEBEXT.readingList.addEntry(entry_ffi); 194 A.store.Ref(retPtr, _ret); 195 return A.H.TRUE; 196 } catch (err: any) { 197 A.store.Ref(errPtr, err); 198 return A.H.FALSE; 199 } 200 }, 201 "has_OnEntryAdded": (): heap.Ref<boolean> => { 202 if (WEBEXT?.readingList?.onEntryAdded && "addListener" in WEBEXT?.readingList?.onEntryAdded) { 203 return A.H.TRUE; 204 } 205 return A.H.FALSE; 206 }, 207 "func_OnEntryAdded": (fn: Pointer): void => { 208 A.store.Ref(fn, WEBEXT.readingList.onEntryAdded.addListener); 209 }, 210 "call_OnEntryAdded": (retPtr: Pointer, callback: heap.Ref<object>): void => { 211 const _ret = WEBEXT.readingList.onEntryAdded.addListener(A.H.get<object>(callback)); 212 }, 213 "try_OnEntryAdded": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 214 try { 215 const _ret = WEBEXT.readingList.onEntryAdded.addListener(A.H.get<object>(callback)); 216 return A.H.TRUE; 217 } catch (err: any) { 218 A.store.Ref(errPtr, err); 219 return A.H.FALSE; 220 } 221 }, 222 "has_OffEntryAdded": (): heap.Ref<boolean> => { 223 if (WEBEXT?.readingList?.onEntryAdded && "removeListener" in WEBEXT?.readingList?.onEntryAdded) { 224 return A.H.TRUE; 225 } 226 return A.H.FALSE; 227 }, 228 "func_OffEntryAdded": (fn: Pointer): void => { 229 A.store.Ref(fn, WEBEXT.readingList.onEntryAdded.removeListener); 230 }, 231 "call_OffEntryAdded": (retPtr: Pointer, callback: heap.Ref<object>): void => { 232 const _ret = WEBEXT.readingList.onEntryAdded.removeListener(A.H.get<object>(callback)); 233 }, 234 "try_OffEntryAdded": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 235 try { 236 const _ret = WEBEXT.readingList.onEntryAdded.removeListener(A.H.get<object>(callback)); 237 return A.H.TRUE; 238 } catch (err: any) { 239 A.store.Ref(errPtr, err); 240 return A.H.FALSE; 241 } 242 }, 243 "has_HasOnEntryAdded": (): heap.Ref<boolean> => { 244 if (WEBEXT?.readingList?.onEntryAdded && "hasListener" in WEBEXT?.readingList?.onEntryAdded) { 245 return A.H.TRUE; 246 } 247 return A.H.FALSE; 248 }, 249 "func_HasOnEntryAdded": (fn: Pointer): void => { 250 A.store.Ref(fn, WEBEXT.readingList.onEntryAdded.hasListener); 251 }, 252 "call_HasOnEntryAdded": (retPtr: Pointer, callback: heap.Ref<object>): void => { 253 const _ret = WEBEXT.readingList.onEntryAdded.hasListener(A.H.get<object>(callback)); 254 A.store.Bool(retPtr, _ret); 255 }, 256 "try_HasOnEntryAdded": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 257 try { 258 const _ret = WEBEXT.readingList.onEntryAdded.hasListener(A.H.get<object>(callback)); 259 A.store.Bool(retPtr, _ret); 260 return A.H.TRUE; 261 } catch (err: any) { 262 A.store.Ref(errPtr, err); 263 return A.H.FALSE; 264 } 265 }, 266 "has_OnEntryRemoved": (): heap.Ref<boolean> => { 267 if (WEBEXT?.readingList?.onEntryRemoved && "addListener" in WEBEXT?.readingList?.onEntryRemoved) { 268 return A.H.TRUE; 269 } 270 return A.H.FALSE; 271 }, 272 "func_OnEntryRemoved": (fn: Pointer): void => { 273 A.store.Ref(fn, WEBEXT.readingList.onEntryRemoved.addListener); 274 }, 275 "call_OnEntryRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => { 276 const _ret = WEBEXT.readingList.onEntryRemoved.addListener(A.H.get<object>(callback)); 277 }, 278 "try_OnEntryRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 279 try { 280 const _ret = WEBEXT.readingList.onEntryRemoved.addListener(A.H.get<object>(callback)); 281 return A.H.TRUE; 282 } catch (err: any) { 283 A.store.Ref(errPtr, err); 284 return A.H.FALSE; 285 } 286 }, 287 "has_OffEntryRemoved": (): heap.Ref<boolean> => { 288 if (WEBEXT?.readingList?.onEntryRemoved && "removeListener" in WEBEXT?.readingList?.onEntryRemoved) { 289 return A.H.TRUE; 290 } 291 return A.H.FALSE; 292 }, 293 "func_OffEntryRemoved": (fn: Pointer): void => { 294 A.store.Ref(fn, WEBEXT.readingList.onEntryRemoved.removeListener); 295 }, 296 "call_OffEntryRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => { 297 const _ret = WEBEXT.readingList.onEntryRemoved.removeListener(A.H.get<object>(callback)); 298 }, 299 "try_OffEntryRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 300 try { 301 const _ret = WEBEXT.readingList.onEntryRemoved.removeListener(A.H.get<object>(callback)); 302 return A.H.TRUE; 303 } catch (err: any) { 304 A.store.Ref(errPtr, err); 305 return A.H.FALSE; 306 } 307 }, 308 "has_HasOnEntryRemoved": (): heap.Ref<boolean> => { 309 if (WEBEXT?.readingList?.onEntryRemoved && "hasListener" in WEBEXT?.readingList?.onEntryRemoved) { 310 return A.H.TRUE; 311 } 312 return A.H.FALSE; 313 }, 314 "func_HasOnEntryRemoved": (fn: Pointer): void => { 315 A.store.Ref(fn, WEBEXT.readingList.onEntryRemoved.hasListener); 316 }, 317 "call_HasOnEntryRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => { 318 const _ret = WEBEXT.readingList.onEntryRemoved.hasListener(A.H.get<object>(callback)); 319 A.store.Bool(retPtr, _ret); 320 }, 321 "try_HasOnEntryRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 322 try { 323 const _ret = WEBEXT.readingList.onEntryRemoved.hasListener(A.H.get<object>(callback)); 324 A.store.Bool(retPtr, _ret); 325 return A.H.TRUE; 326 } catch (err: any) { 327 A.store.Ref(errPtr, err); 328 return A.H.FALSE; 329 } 330 }, 331 "has_OnEntryUpdated": (): heap.Ref<boolean> => { 332 if (WEBEXT?.readingList?.onEntryUpdated && "addListener" in WEBEXT?.readingList?.onEntryUpdated) { 333 return A.H.TRUE; 334 } 335 return A.H.FALSE; 336 }, 337 "func_OnEntryUpdated": (fn: Pointer): void => { 338 A.store.Ref(fn, WEBEXT.readingList.onEntryUpdated.addListener); 339 }, 340 "call_OnEntryUpdated": (retPtr: Pointer, callback: heap.Ref<object>): void => { 341 const _ret = WEBEXT.readingList.onEntryUpdated.addListener(A.H.get<object>(callback)); 342 }, 343 "try_OnEntryUpdated": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 344 try { 345 const _ret = WEBEXT.readingList.onEntryUpdated.addListener(A.H.get<object>(callback)); 346 return A.H.TRUE; 347 } catch (err: any) { 348 A.store.Ref(errPtr, err); 349 return A.H.FALSE; 350 } 351 }, 352 "has_OffEntryUpdated": (): heap.Ref<boolean> => { 353 if (WEBEXT?.readingList?.onEntryUpdated && "removeListener" in WEBEXT?.readingList?.onEntryUpdated) { 354 return A.H.TRUE; 355 } 356 return A.H.FALSE; 357 }, 358 "func_OffEntryUpdated": (fn: Pointer): void => { 359 A.store.Ref(fn, WEBEXT.readingList.onEntryUpdated.removeListener); 360 }, 361 "call_OffEntryUpdated": (retPtr: Pointer, callback: heap.Ref<object>): void => { 362 const _ret = WEBEXT.readingList.onEntryUpdated.removeListener(A.H.get<object>(callback)); 363 }, 364 "try_OffEntryUpdated": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 365 try { 366 const _ret = WEBEXT.readingList.onEntryUpdated.removeListener(A.H.get<object>(callback)); 367 return A.H.TRUE; 368 } catch (err: any) { 369 A.store.Ref(errPtr, err); 370 return A.H.FALSE; 371 } 372 }, 373 "has_HasOnEntryUpdated": (): heap.Ref<boolean> => { 374 if (WEBEXT?.readingList?.onEntryUpdated && "hasListener" in WEBEXT?.readingList?.onEntryUpdated) { 375 return A.H.TRUE; 376 } 377 return A.H.FALSE; 378 }, 379 "func_HasOnEntryUpdated": (fn: Pointer): void => { 380 A.store.Ref(fn, WEBEXT.readingList.onEntryUpdated.hasListener); 381 }, 382 "call_HasOnEntryUpdated": (retPtr: Pointer, callback: heap.Ref<object>): void => { 383 const _ret = WEBEXT.readingList.onEntryUpdated.hasListener(A.H.get<object>(callback)); 384 A.store.Bool(retPtr, _ret); 385 }, 386 "try_HasOnEntryUpdated": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 387 try { 388 const _ret = WEBEXT.readingList.onEntryUpdated.hasListener(A.H.get<object>(callback)); 389 A.store.Bool(retPtr, _ret); 390 return A.H.TRUE; 391 } catch (err: any) { 392 A.store.Ref(errPtr, err); 393 return A.H.FALSE; 394 } 395 }, 396 "has_Query": (): heap.Ref<boolean> => { 397 if (WEBEXT?.readingList && "query" in WEBEXT?.readingList) { 398 return A.H.TRUE; 399 } 400 return A.H.FALSE; 401 }, 402 "func_Query": (fn: Pointer): void => { 403 A.store.Ref(fn, WEBEXT.readingList.query); 404 }, 405 "call_Query": (retPtr: Pointer, info: Pointer): void => { 406 const info_ffi = {}; 407 408 info_ffi["url"] = A.load.Ref(info + 0, undefined); 409 info_ffi["title"] = A.load.Ref(info + 4, undefined); 410 if (A.load.Bool(info + 9)) { 411 info_ffi["hasBeenRead"] = A.load.Bool(info + 8); 412 } 413 414 const _ret = WEBEXT.readingList.query(info_ffi); 415 A.store.Ref(retPtr, _ret); 416 }, 417 "try_Query": (retPtr: Pointer, errPtr: Pointer, info: Pointer): heap.Ref<boolean> => { 418 try { 419 const info_ffi = {}; 420 421 info_ffi["url"] = A.load.Ref(info + 0, undefined); 422 info_ffi["title"] = A.load.Ref(info + 4, undefined); 423 if (A.load.Bool(info + 9)) { 424 info_ffi["hasBeenRead"] = A.load.Bool(info + 8); 425 } 426 427 const _ret = WEBEXT.readingList.query(info_ffi); 428 A.store.Ref(retPtr, _ret); 429 return A.H.TRUE; 430 } catch (err: any) { 431 A.store.Ref(errPtr, err); 432 return A.H.FALSE; 433 } 434 }, 435 "has_RemoveEntry": (): heap.Ref<boolean> => { 436 if (WEBEXT?.readingList && "removeEntry" in WEBEXT?.readingList) { 437 return A.H.TRUE; 438 } 439 return A.H.FALSE; 440 }, 441 "func_RemoveEntry": (fn: Pointer): void => { 442 A.store.Ref(fn, WEBEXT.readingList.removeEntry); 443 }, 444 "call_RemoveEntry": (retPtr: Pointer, info: Pointer): void => { 445 const info_ffi = {}; 446 447 info_ffi["url"] = A.load.Ref(info + 0, undefined); 448 449 const _ret = WEBEXT.readingList.removeEntry(info_ffi); 450 A.store.Ref(retPtr, _ret); 451 }, 452 "try_RemoveEntry": (retPtr: Pointer, errPtr: Pointer, info: Pointer): heap.Ref<boolean> => { 453 try { 454 const info_ffi = {}; 455 456 info_ffi["url"] = A.load.Ref(info + 0, undefined); 457 458 const _ret = WEBEXT.readingList.removeEntry(info_ffi); 459 A.store.Ref(retPtr, _ret); 460 return A.H.TRUE; 461 } catch (err: any) { 462 A.store.Ref(errPtr, err); 463 return A.H.FALSE; 464 } 465 }, 466 "has_UpdateEntry": (): heap.Ref<boolean> => { 467 if (WEBEXT?.readingList && "updateEntry" in WEBEXT?.readingList) { 468 return A.H.TRUE; 469 } 470 return A.H.FALSE; 471 }, 472 "func_UpdateEntry": (fn: Pointer): void => { 473 A.store.Ref(fn, WEBEXT.readingList.updateEntry); 474 }, 475 "call_UpdateEntry": (retPtr: Pointer, info: Pointer): void => { 476 const info_ffi = {}; 477 478 info_ffi["url"] = A.load.Ref(info + 0, undefined); 479 info_ffi["title"] = A.load.Ref(info + 4, undefined); 480 if (A.load.Bool(info + 9)) { 481 info_ffi["hasBeenRead"] = A.load.Bool(info + 8); 482 } 483 484 const _ret = WEBEXT.readingList.updateEntry(info_ffi); 485 A.store.Ref(retPtr, _ret); 486 }, 487 "try_UpdateEntry": (retPtr: Pointer, errPtr: Pointer, info: Pointer): heap.Ref<boolean> => { 488 try { 489 const info_ffi = {}; 490 491 info_ffi["url"] = A.load.Ref(info + 0, undefined); 492 info_ffi["title"] = A.load.Ref(info + 4, undefined); 493 if (A.load.Bool(info + 9)) { 494 info_ffi["hasBeenRead"] = A.load.Bool(info + 8); 495 } 496 497 const _ret = WEBEXT.readingList.updateEntry(info_ffi); 498 A.store.Ref(retPtr, _ret); 499 return A.H.TRUE; 500 } catch (err: any) { 501 A.store.Ref(errPtr, err); 502 return A.H.FALSE; 503 } 504 }, 505 }; 506 });