github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/terminalprivate/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/terminalprivate", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_GetOSInfoReturnType": (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 + 2, false); 12 A.store.Bool(ptr + 0, false); 13 A.store.Bool(ptr + 1, false); 14 } else { 15 A.store.Bool(ptr + 2, true); 16 A.store.Bool(ptr + 0, x["alternative_emulator"] ? true : false); 17 A.store.Bool(ptr + 1, x["tast"] ? true : false); 18 } 19 }, 20 "load_GetOSInfoReturnType": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 21 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 22 23 x["alternative_emulator"] = A.load.Bool(ptr + 0); 24 x["tast"] = A.load.Bool(ptr + 1); 25 return create === A.H.TRUE ? A.H.push(x) : ref; 26 }, 27 28 "store_OpenWindowArgData": (ptr: Pointer, ref: heap.Ref<any>) => { 29 const x = A.H.get<any>(ref); 30 31 if (typeof x === "undefined") { 32 A.store.Bool(ptr + 9, false); 33 A.store.Bool(ptr + 8, false); 34 A.store.Bool(ptr + 0, false); 35 A.store.Ref(ptr + 4, undefined); 36 } else { 37 A.store.Bool(ptr + 9, true); 38 A.store.Bool(ptr + 8, "asTab" in x ? true : false); 39 A.store.Bool(ptr + 0, x["asTab"] ? true : false); 40 A.store.Ref(ptr + 4, x["url"]); 41 } 42 }, 43 "load_OpenWindowArgData": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 44 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 45 46 if (A.load.Bool(ptr + 8)) { 47 x["asTab"] = A.load.Bool(ptr + 0); 48 } else { 49 delete x["asTab"]; 50 } 51 x["url"] = A.load.Ref(ptr + 4, undefined); 52 return create === A.H.TRUE ? A.H.push(x) : ref; 53 }, 54 "constof_OutputType": (ref: heap.Ref<string>): number => { 55 const idx = ["stdout", "stderr", "exit"].indexOf(A.H.get(ref)); 56 return idx < 0 ? 0 : idx + 1; 57 }, 58 "has_AckOutput": (): heap.Ref<boolean> => { 59 if (WEBEXT?.terminalPrivate && "ackOutput" in WEBEXT?.terminalPrivate) { 60 return A.H.TRUE; 61 } 62 return A.H.FALSE; 63 }, 64 "func_AckOutput": (fn: Pointer): void => { 65 A.store.Ref(fn, WEBEXT.terminalPrivate.ackOutput); 66 }, 67 "call_AckOutput": (retPtr: Pointer, id: heap.Ref<object>): void => { 68 const _ret = WEBEXT.terminalPrivate.ackOutput(A.H.get<object>(id)); 69 }, 70 "try_AckOutput": (retPtr: Pointer, errPtr: Pointer, id: heap.Ref<object>): heap.Ref<boolean> => { 71 try { 72 const _ret = WEBEXT.terminalPrivate.ackOutput(A.H.get<object>(id)); 73 return A.H.TRUE; 74 } catch (err: any) { 75 A.store.Ref(errPtr, err); 76 return A.H.FALSE; 77 } 78 }, 79 "has_CloseTerminalProcess": (): heap.Ref<boolean> => { 80 if (WEBEXT?.terminalPrivate && "closeTerminalProcess" in WEBEXT?.terminalPrivate) { 81 return A.H.TRUE; 82 } 83 return A.H.FALSE; 84 }, 85 "func_CloseTerminalProcess": (fn: Pointer): void => { 86 A.store.Ref(fn, WEBEXT.terminalPrivate.closeTerminalProcess); 87 }, 88 "call_CloseTerminalProcess": (retPtr: Pointer, id: heap.Ref<object>): void => { 89 const _ret = WEBEXT.terminalPrivate.closeTerminalProcess(A.H.get<object>(id)); 90 A.store.Ref(retPtr, _ret); 91 }, 92 "try_CloseTerminalProcess": (retPtr: Pointer, errPtr: Pointer, id: heap.Ref<object>): heap.Ref<boolean> => { 93 try { 94 const _ret = WEBEXT.terminalPrivate.closeTerminalProcess(A.H.get<object>(id)); 95 A.store.Ref(retPtr, _ret); 96 return A.H.TRUE; 97 } catch (err: any) { 98 A.store.Ref(errPtr, err); 99 return A.H.FALSE; 100 } 101 }, 102 "has_GetOSInfo": (): heap.Ref<boolean> => { 103 if (WEBEXT?.terminalPrivate && "getOSInfo" in WEBEXT?.terminalPrivate) { 104 return A.H.TRUE; 105 } 106 return A.H.FALSE; 107 }, 108 "func_GetOSInfo": (fn: Pointer): void => { 109 A.store.Ref(fn, WEBEXT.terminalPrivate.getOSInfo); 110 }, 111 "call_GetOSInfo": (retPtr: Pointer): void => { 112 const _ret = WEBEXT.terminalPrivate.getOSInfo(); 113 A.store.Ref(retPtr, _ret); 114 }, 115 "try_GetOSInfo": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 116 try { 117 const _ret = WEBEXT.terminalPrivate.getOSInfo(); 118 A.store.Ref(retPtr, _ret); 119 return A.H.TRUE; 120 } catch (err: any) { 121 A.store.Ref(errPtr, err); 122 return A.H.FALSE; 123 } 124 }, 125 "has_GetPrefs": (): heap.Ref<boolean> => { 126 if (WEBEXT?.terminalPrivate && "getPrefs" in WEBEXT?.terminalPrivate) { 127 return A.H.TRUE; 128 } 129 return A.H.FALSE; 130 }, 131 "func_GetPrefs": (fn: Pointer): void => { 132 A.store.Ref(fn, WEBEXT.terminalPrivate.getPrefs); 133 }, 134 "call_GetPrefs": (retPtr: Pointer, paths: heap.Ref<object>): void => { 135 const _ret = WEBEXT.terminalPrivate.getPrefs(A.H.get<object>(paths)); 136 A.store.Ref(retPtr, _ret); 137 }, 138 "try_GetPrefs": (retPtr: Pointer, errPtr: Pointer, paths: heap.Ref<object>): heap.Ref<boolean> => { 139 try { 140 const _ret = WEBEXT.terminalPrivate.getPrefs(A.H.get<object>(paths)); 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_OnPrefChanged": (): heap.Ref<boolean> => { 149 if (WEBEXT?.terminalPrivate?.onPrefChanged && "addListener" in WEBEXT?.terminalPrivate?.onPrefChanged) { 150 return A.H.TRUE; 151 } 152 return A.H.FALSE; 153 }, 154 "func_OnPrefChanged": (fn: Pointer): void => { 155 A.store.Ref(fn, WEBEXT.terminalPrivate.onPrefChanged.addListener); 156 }, 157 "call_OnPrefChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 158 const _ret = WEBEXT.terminalPrivate.onPrefChanged.addListener(A.H.get<object>(callback)); 159 }, 160 "try_OnPrefChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 161 try { 162 const _ret = WEBEXT.terminalPrivate.onPrefChanged.addListener(A.H.get<object>(callback)); 163 return A.H.TRUE; 164 } catch (err: any) { 165 A.store.Ref(errPtr, err); 166 return A.H.FALSE; 167 } 168 }, 169 "has_OffPrefChanged": (): heap.Ref<boolean> => { 170 if (WEBEXT?.terminalPrivate?.onPrefChanged && "removeListener" in WEBEXT?.terminalPrivate?.onPrefChanged) { 171 return A.H.TRUE; 172 } 173 return A.H.FALSE; 174 }, 175 "func_OffPrefChanged": (fn: Pointer): void => { 176 A.store.Ref(fn, WEBEXT.terminalPrivate.onPrefChanged.removeListener); 177 }, 178 "call_OffPrefChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 179 const _ret = WEBEXT.terminalPrivate.onPrefChanged.removeListener(A.H.get<object>(callback)); 180 }, 181 "try_OffPrefChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 182 try { 183 const _ret = WEBEXT.terminalPrivate.onPrefChanged.removeListener(A.H.get<object>(callback)); 184 return A.H.TRUE; 185 } catch (err: any) { 186 A.store.Ref(errPtr, err); 187 return A.H.FALSE; 188 } 189 }, 190 "has_HasOnPrefChanged": (): heap.Ref<boolean> => { 191 if (WEBEXT?.terminalPrivate?.onPrefChanged && "hasListener" in WEBEXT?.terminalPrivate?.onPrefChanged) { 192 return A.H.TRUE; 193 } 194 return A.H.FALSE; 195 }, 196 "func_HasOnPrefChanged": (fn: Pointer): void => { 197 A.store.Ref(fn, WEBEXT.terminalPrivate.onPrefChanged.hasListener); 198 }, 199 "call_HasOnPrefChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 200 const _ret = WEBEXT.terminalPrivate.onPrefChanged.hasListener(A.H.get<object>(callback)); 201 A.store.Bool(retPtr, _ret); 202 }, 203 "try_HasOnPrefChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 204 try { 205 const _ret = WEBEXT.terminalPrivate.onPrefChanged.hasListener(A.H.get<object>(callback)); 206 A.store.Bool(retPtr, _ret); 207 return A.H.TRUE; 208 } catch (err: any) { 209 A.store.Ref(errPtr, err); 210 return A.H.FALSE; 211 } 212 }, 213 "has_OnProcessOutput": (): heap.Ref<boolean> => { 214 if (WEBEXT?.terminalPrivate?.onProcessOutput && "addListener" in WEBEXT?.terminalPrivate?.onProcessOutput) { 215 return A.H.TRUE; 216 } 217 return A.H.FALSE; 218 }, 219 "func_OnProcessOutput": (fn: Pointer): void => { 220 A.store.Ref(fn, WEBEXT.terminalPrivate.onProcessOutput.addListener); 221 }, 222 "call_OnProcessOutput": (retPtr: Pointer, callback: heap.Ref<object>): void => { 223 const _ret = WEBEXT.terminalPrivate.onProcessOutput.addListener(A.H.get<object>(callback)); 224 }, 225 "try_OnProcessOutput": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 226 try { 227 const _ret = WEBEXT.terminalPrivate.onProcessOutput.addListener(A.H.get<object>(callback)); 228 return A.H.TRUE; 229 } catch (err: any) { 230 A.store.Ref(errPtr, err); 231 return A.H.FALSE; 232 } 233 }, 234 "has_OffProcessOutput": (): heap.Ref<boolean> => { 235 if (WEBEXT?.terminalPrivate?.onProcessOutput && "removeListener" in WEBEXT?.terminalPrivate?.onProcessOutput) { 236 return A.H.TRUE; 237 } 238 return A.H.FALSE; 239 }, 240 "func_OffProcessOutput": (fn: Pointer): void => { 241 A.store.Ref(fn, WEBEXT.terminalPrivate.onProcessOutput.removeListener); 242 }, 243 "call_OffProcessOutput": (retPtr: Pointer, callback: heap.Ref<object>): void => { 244 const _ret = WEBEXT.terminalPrivate.onProcessOutput.removeListener(A.H.get<object>(callback)); 245 }, 246 "try_OffProcessOutput": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 247 try { 248 const _ret = WEBEXT.terminalPrivate.onProcessOutput.removeListener(A.H.get<object>(callback)); 249 return A.H.TRUE; 250 } catch (err: any) { 251 A.store.Ref(errPtr, err); 252 return A.H.FALSE; 253 } 254 }, 255 "has_HasOnProcessOutput": (): heap.Ref<boolean> => { 256 if (WEBEXT?.terminalPrivate?.onProcessOutput && "hasListener" in WEBEXT?.terminalPrivate?.onProcessOutput) { 257 return A.H.TRUE; 258 } 259 return A.H.FALSE; 260 }, 261 "func_HasOnProcessOutput": (fn: Pointer): void => { 262 A.store.Ref(fn, WEBEXT.terminalPrivate.onProcessOutput.hasListener); 263 }, 264 "call_HasOnProcessOutput": (retPtr: Pointer, callback: heap.Ref<object>): void => { 265 const _ret = WEBEXT.terminalPrivate.onProcessOutput.hasListener(A.H.get<object>(callback)); 266 A.store.Bool(retPtr, _ret); 267 }, 268 "try_HasOnProcessOutput": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 269 try { 270 const _ret = WEBEXT.terminalPrivate.onProcessOutput.hasListener(A.H.get<object>(callback)); 271 A.store.Bool(retPtr, _ret); 272 return A.H.TRUE; 273 } catch (err: any) { 274 A.store.Ref(errPtr, err); 275 return A.H.FALSE; 276 } 277 }, 278 "has_OnTerminalResize": (): heap.Ref<boolean> => { 279 if (WEBEXT?.terminalPrivate && "onTerminalResize" in WEBEXT?.terminalPrivate) { 280 return A.H.TRUE; 281 } 282 return A.H.FALSE; 283 }, 284 "func_OnTerminalResize": (fn: Pointer): void => { 285 A.store.Ref(fn, WEBEXT.terminalPrivate.onTerminalResize); 286 }, 287 "call_OnTerminalResize": (retPtr: Pointer, id: heap.Ref<object>, width: number, height: number): void => { 288 const _ret = WEBEXT.terminalPrivate.onTerminalResize(A.H.get<object>(id), width, height); 289 A.store.Ref(retPtr, _ret); 290 }, 291 "try_OnTerminalResize": ( 292 retPtr: Pointer, 293 errPtr: Pointer, 294 id: heap.Ref<object>, 295 width: number, 296 height: number 297 ): heap.Ref<boolean> => { 298 try { 299 const _ret = WEBEXT.terminalPrivate.onTerminalResize(A.H.get<object>(id), width, height); 300 A.store.Ref(retPtr, _ret); 301 return A.H.TRUE; 302 } catch (err: any) { 303 A.store.Ref(errPtr, err); 304 return A.H.FALSE; 305 } 306 }, 307 "has_OpenOptionsPage": (): heap.Ref<boolean> => { 308 if (WEBEXT?.terminalPrivate && "openOptionsPage" in WEBEXT?.terminalPrivate) { 309 return A.H.TRUE; 310 } 311 return A.H.FALSE; 312 }, 313 "func_OpenOptionsPage": (fn: Pointer): void => { 314 A.store.Ref(fn, WEBEXT.terminalPrivate.openOptionsPage); 315 }, 316 "call_OpenOptionsPage": (retPtr: Pointer): void => { 317 const _ret = WEBEXT.terminalPrivate.openOptionsPage(); 318 A.store.Ref(retPtr, _ret); 319 }, 320 "try_OpenOptionsPage": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 321 try { 322 const _ret = WEBEXT.terminalPrivate.openOptionsPage(); 323 A.store.Ref(retPtr, _ret); 324 return A.H.TRUE; 325 } catch (err: any) { 326 A.store.Ref(errPtr, err); 327 return A.H.FALSE; 328 } 329 }, 330 "has_OpenSettingsSubpage": (): heap.Ref<boolean> => { 331 if (WEBEXT?.terminalPrivate && "openSettingsSubpage" in WEBEXT?.terminalPrivate) { 332 return A.H.TRUE; 333 } 334 return A.H.FALSE; 335 }, 336 "func_OpenSettingsSubpage": (fn: Pointer): void => { 337 A.store.Ref(fn, WEBEXT.terminalPrivate.openSettingsSubpage); 338 }, 339 "call_OpenSettingsSubpage": (retPtr: Pointer, subpage: heap.Ref<object>): void => { 340 const _ret = WEBEXT.terminalPrivate.openSettingsSubpage(A.H.get<object>(subpage)); 341 A.store.Ref(retPtr, _ret); 342 }, 343 "try_OpenSettingsSubpage": (retPtr: Pointer, errPtr: Pointer, subpage: heap.Ref<object>): heap.Ref<boolean> => { 344 try { 345 const _ret = WEBEXT.terminalPrivate.openSettingsSubpage(A.H.get<object>(subpage)); 346 A.store.Ref(retPtr, _ret); 347 return A.H.TRUE; 348 } catch (err: any) { 349 A.store.Ref(errPtr, err); 350 return A.H.FALSE; 351 } 352 }, 353 "has_OpenTerminalProcess": (): heap.Ref<boolean> => { 354 if (WEBEXT?.terminalPrivate && "openTerminalProcess" in WEBEXT?.terminalPrivate) { 355 return A.H.TRUE; 356 } 357 return A.H.FALSE; 358 }, 359 "func_OpenTerminalProcess": (fn: Pointer): void => { 360 A.store.Ref(fn, WEBEXT.terminalPrivate.openTerminalProcess); 361 }, 362 "call_OpenTerminalProcess": (retPtr: Pointer, processName: heap.Ref<object>, args: heap.Ref<object>): void => { 363 const _ret = WEBEXT.terminalPrivate.openTerminalProcess(A.H.get<object>(processName), A.H.get<object>(args)); 364 A.store.Ref(retPtr, _ret); 365 }, 366 "try_OpenTerminalProcess": ( 367 retPtr: Pointer, 368 errPtr: Pointer, 369 processName: heap.Ref<object>, 370 args: heap.Ref<object> 371 ): heap.Ref<boolean> => { 372 try { 373 const _ret = WEBEXT.terminalPrivate.openTerminalProcess(A.H.get<object>(processName), A.H.get<object>(args)); 374 A.store.Ref(retPtr, _ret); 375 return A.H.TRUE; 376 } catch (err: any) { 377 A.store.Ref(errPtr, err); 378 return A.H.FALSE; 379 } 380 }, 381 "has_OpenVmshellProcess": (): heap.Ref<boolean> => { 382 if (WEBEXT?.terminalPrivate && "openVmshellProcess" in WEBEXT?.terminalPrivate) { 383 return A.H.TRUE; 384 } 385 return A.H.FALSE; 386 }, 387 "func_OpenVmshellProcess": (fn: Pointer): void => { 388 A.store.Ref(fn, WEBEXT.terminalPrivate.openVmshellProcess); 389 }, 390 "call_OpenVmshellProcess": (retPtr: Pointer, args: heap.Ref<object>): void => { 391 const _ret = WEBEXT.terminalPrivate.openVmshellProcess(A.H.get<object>(args)); 392 A.store.Ref(retPtr, _ret); 393 }, 394 "try_OpenVmshellProcess": (retPtr: Pointer, errPtr: Pointer, args: heap.Ref<object>): heap.Ref<boolean> => { 395 try { 396 const _ret = WEBEXT.terminalPrivate.openVmshellProcess(A.H.get<object>(args)); 397 A.store.Ref(retPtr, _ret); 398 return A.H.TRUE; 399 } catch (err: any) { 400 A.store.Ref(errPtr, err); 401 return A.H.FALSE; 402 } 403 }, 404 "has_OpenWindow": (): heap.Ref<boolean> => { 405 if (WEBEXT?.terminalPrivate && "openWindow" in WEBEXT?.terminalPrivate) { 406 return A.H.TRUE; 407 } 408 return A.H.FALSE; 409 }, 410 "func_OpenWindow": (fn: Pointer): void => { 411 A.store.Ref(fn, WEBEXT.terminalPrivate.openWindow); 412 }, 413 "call_OpenWindow": (retPtr: Pointer, data: Pointer): void => { 414 const data_ffi = {}; 415 416 if (A.load.Bool(data + 8)) { 417 data_ffi["asTab"] = A.load.Bool(data + 0); 418 } 419 data_ffi["url"] = A.load.Ref(data + 4, undefined); 420 421 const _ret = WEBEXT.terminalPrivate.openWindow(data_ffi); 422 }, 423 "try_OpenWindow": (retPtr: Pointer, errPtr: Pointer, data: Pointer): heap.Ref<boolean> => { 424 try { 425 const data_ffi = {}; 426 427 if (A.load.Bool(data + 8)) { 428 data_ffi["asTab"] = A.load.Bool(data + 0); 429 } 430 data_ffi["url"] = A.load.Ref(data + 4, undefined); 431 432 const _ret = WEBEXT.terminalPrivate.openWindow(data_ffi); 433 return A.H.TRUE; 434 } catch (err: any) { 435 A.store.Ref(errPtr, err); 436 return A.H.FALSE; 437 } 438 }, 439 "has_SendInput": (): heap.Ref<boolean> => { 440 if (WEBEXT?.terminalPrivate && "sendInput" in WEBEXT?.terminalPrivate) { 441 return A.H.TRUE; 442 } 443 return A.H.FALSE; 444 }, 445 "func_SendInput": (fn: Pointer): void => { 446 A.store.Ref(fn, WEBEXT.terminalPrivate.sendInput); 447 }, 448 "call_SendInput": (retPtr: Pointer, id: heap.Ref<object>, input: heap.Ref<object>): void => { 449 const _ret = WEBEXT.terminalPrivate.sendInput(A.H.get<object>(id), A.H.get<object>(input)); 450 A.store.Ref(retPtr, _ret); 451 }, 452 "try_SendInput": ( 453 retPtr: Pointer, 454 errPtr: Pointer, 455 id: heap.Ref<object>, 456 input: heap.Ref<object> 457 ): heap.Ref<boolean> => { 458 try { 459 const _ret = WEBEXT.terminalPrivate.sendInput(A.H.get<object>(id), A.H.get<object>(input)); 460 A.store.Ref(retPtr, _ret); 461 return A.H.TRUE; 462 } catch (err: any) { 463 A.store.Ref(errPtr, err); 464 return A.H.FALSE; 465 } 466 }, 467 "has_SetPrefs": (): heap.Ref<boolean> => { 468 if (WEBEXT?.terminalPrivate && "setPrefs" in WEBEXT?.terminalPrivate) { 469 return A.H.TRUE; 470 } 471 return A.H.FALSE; 472 }, 473 "func_SetPrefs": (fn: Pointer): void => { 474 A.store.Ref(fn, WEBEXT.terminalPrivate.setPrefs); 475 }, 476 "call_SetPrefs": (retPtr: Pointer, prefs: heap.Ref<object>): void => { 477 const _ret = WEBEXT.terminalPrivate.setPrefs(A.H.get<object>(prefs)); 478 A.store.Ref(retPtr, _ret); 479 }, 480 "try_SetPrefs": (retPtr: Pointer, errPtr: Pointer, prefs: heap.Ref<object>): heap.Ref<boolean> => { 481 try { 482 const _ret = WEBEXT.terminalPrivate.setPrefs(A.H.get<object>(prefs)); 483 A.store.Ref(retPtr, _ret); 484 return A.H.TRUE; 485 } catch (err: any) { 486 A.store.Ref(errPtr, err); 487 return A.H.FALSE; 488 } 489 }, 490 }; 491 });