github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/guestviewinternal/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/guestviewinternal", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_Size": (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 + 16, false); 12 A.store.Int64(ptr + 0, 0); 13 A.store.Int64(ptr + 8, 0); 14 } else { 15 A.store.Bool(ptr + 16, true); 16 A.store.Int64(ptr + 0, x["height"] === undefined ? 0 : (x["height"] as number)); 17 A.store.Int64(ptr + 8, x["width"] === undefined ? 0 : (x["width"] as number)); 18 } 19 }, 20 "load_Size": (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["height"] = A.load.Int64(ptr + 0); 24 x["width"] = A.load.Int64(ptr + 8); 25 return create === A.H.TRUE ? A.H.push(x) : ref; 26 }, 27 28 "store_SizeParams": (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 + 74, false); 33 A.store.Bool(ptr + 73, false); 34 A.store.Bool(ptr + 0, false); 35 36 A.store.Bool(ptr + 8 + 16, false); 37 A.store.Int64(ptr + 8 + 0, 0); 38 A.store.Int64(ptr + 8 + 8, 0); 39 40 A.store.Bool(ptr + 32 + 16, false); 41 A.store.Int64(ptr + 32 + 0, 0); 42 A.store.Int64(ptr + 32 + 8, 0); 43 44 A.store.Bool(ptr + 56 + 16, false); 45 A.store.Int64(ptr + 56 + 0, 0); 46 A.store.Int64(ptr + 56 + 8, 0); 47 } else { 48 A.store.Bool(ptr + 74, true); 49 A.store.Bool(ptr + 73, "enableAutoSize" in x ? true : false); 50 A.store.Bool(ptr + 0, x["enableAutoSize"] ? true : false); 51 52 if (typeof x["max"] === "undefined") { 53 A.store.Bool(ptr + 8 + 16, false); 54 A.store.Int64(ptr + 8 + 0, 0); 55 A.store.Int64(ptr + 8 + 8, 0); 56 } else { 57 A.store.Bool(ptr + 8 + 16, true); 58 A.store.Int64(ptr + 8 + 0, x["max"]["height"] === undefined ? 0 : (x["max"]["height"] as number)); 59 A.store.Int64(ptr + 8 + 8, x["max"]["width"] === undefined ? 0 : (x["max"]["width"] as number)); 60 } 61 62 if (typeof x["min"] === "undefined") { 63 A.store.Bool(ptr + 32 + 16, false); 64 A.store.Int64(ptr + 32 + 0, 0); 65 A.store.Int64(ptr + 32 + 8, 0); 66 } else { 67 A.store.Bool(ptr + 32 + 16, true); 68 A.store.Int64(ptr + 32 + 0, x["min"]["height"] === undefined ? 0 : (x["min"]["height"] as number)); 69 A.store.Int64(ptr + 32 + 8, x["min"]["width"] === undefined ? 0 : (x["min"]["width"] as number)); 70 } 71 72 if (typeof x["normal"] === "undefined") { 73 A.store.Bool(ptr + 56 + 16, false); 74 A.store.Int64(ptr + 56 + 0, 0); 75 A.store.Int64(ptr + 56 + 8, 0); 76 } else { 77 A.store.Bool(ptr + 56 + 16, true); 78 A.store.Int64(ptr + 56 + 0, x["normal"]["height"] === undefined ? 0 : (x["normal"]["height"] as number)); 79 A.store.Int64(ptr + 56 + 8, x["normal"]["width"] === undefined ? 0 : (x["normal"]["width"] as number)); 80 } 81 } 82 }, 83 "load_SizeParams": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 84 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 85 86 if (A.load.Bool(ptr + 73)) { 87 x["enableAutoSize"] = A.load.Bool(ptr + 0); 88 } else { 89 delete x["enableAutoSize"]; 90 } 91 if (A.load.Bool(ptr + 8 + 16)) { 92 x["max"] = {}; 93 x["max"]["height"] = A.load.Int64(ptr + 8 + 0); 94 x["max"]["width"] = A.load.Int64(ptr + 8 + 8); 95 } else { 96 delete x["max"]; 97 } 98 if (A.load.Bool(ptr + 32 + 16)) { 99 x["min"] = {}; 100 x["min"]["height"] = A.load.Int64(ptr + 32 + 0); 101 x["min"]["width"] = A.load.Int64(ptr + 32 + 8); 102 } else { 103 delete x["min"]; 104 } 105 if (A.load.Bool(ptr + 56 + 16)) { 106 x["normal"] = {}; 107 x["normal"]["height"] = A.load.Int64(ptr + 56 + 0); 108 x["normal"]["width"] = A.load.Int64(ptr + 56 + 8); 109 } else { 110 delete x["normal"]; 111 } 112 return create === A.H.TRUE ? A.H.push(x) : ref; 113 }, 114 "has_CreateGuest": (): heap.Ref<boolean> => { 115 if (WEBEXT?.guestViewInternal && "createGuest" in WEBEXT?.guestViewInternal) { 116 return A.H.TRUE; 117 } 118 return A.H.FALSE; 119 }, 120 "func_CreateGuest": (fn: Pointer): void => { 121 A.store.Ref(fn, WEBEXT.guestViewInternal.createGuest); 122 }, 123 "call_CreateGuest": ( 124 retPtr: Pointer, 125 viewType: heap.Ref<object>, 126 ownerRoutingId: number, 127 createParams: heap.Ref<object> 128 ): void => { 129 const _ret = WEBEXT.guestViewInternal.createGuest( 130 A.H.get<object>(viewType), 131 ownerRoutingId, 132 A.H.get<object>(createParams) 133 ); 134 A.store.Ref(retPtr, _ret); 135 }, 136 "try_CreateGuest": ( 137 retPtr: Pointer, 138 errPtr: Pointer, 139 viewType: heap.Ref<object>, 140 ownerRoutingId: number, 141 createParams: heap.Ref<object> 142 ): heap.Ref<boolean> => { 143 try { 144 const _ret = WEBEXT.guestViewInternal.createGuest( 145 A.H.get<object>(viewType), 146 ownerRoutingId, 147 A.H.get<object>(createParams) 148 ); 149 A.store.Ref(retPtr, _ret); 150 return A.H.TRUE; 151 } catch (err: any) { 152 A.store.Ref(errPtr, err); 153 return A.H.FALSE; 154 } 155 }, 156 "has_DestroyUnattachedGuest": (): heap.Ref<boolean> => { 157 if (WEBEXT?.guestViewInternal && "destroyUnattachedGuest" in WEBEXT?.guestViewInternal) { 158 return A.H.TRUE; 159 } 160 return A.H.FALSE; 161 }, 162 "func_DestroyUnattachedGuest": (fn: Pointer): void => { 163 A.store.Ref(fn, WEBEXT.guestViewInternal.destroyUnattachedGuest); 164 }, 165 "call_DestroyUnattachedGuest": (retPtr: Pointer, instanceId: number): void => { 166 const _ret = WEBEXT.guestViewInternal.destroyUnattachedGuest(instanceId); 167 }, 168 "try_DestroyUnattachedGuest": (retPtr: Pointer, errPtr: Pointer, instanceId: number): heap.Ref<boolean> => { 169 try { 170 const _ret = WEBEXT.guestViewInternal.destroyUnattachedGuest(instanceId); 171 return A.H.TRUE; 172 } catch (err: any) { 173 A.store.Ref(errPtr, err); 174 return A.H.FALSE; 175 } 176 }, 177 "has_SetSize": (): heap.Ref<boolean> => { 178 if (WEBEXT?.guestViewInternal && "setSize" in WEBEXT?.guestViewInternal) { 179 return A.H.TRUE; 180 } 181 return A.H.FALSE; 182 }, 183 "func_SetSize": (fn: Pointer): void => { 184 A.store.Ref(fn, WEBEXT.guestViewInternal.setSize); 185 }, 186 "call_SetSize": (retPtr: Pointer, instanceId: number, params: Pointer): void => { 187 const params_ffi = {}; 188 189 if (A.load.Bool(params + 73)) { 190 params_ffi["enableAutoSize"] = A.load.Bool(params + 0); 191 } 192 if (A.load.Bool(params + 8 + 16)) { 193 params_ffi["max"] = {}; 194 params_ffi["max"]["height"] = A.load.Int64(params + 8 + 0); 195 params_ffi["max"]["width"] = A.load.Int64(params + 8 + 8); 196 } 197 if (A.load.Bool(params + 32 + 16)) { 198 params_ffi["min"] = {}; 199 params_ffi["min"]["height"] = A.load.Int64(params + 32 + 0); 200 params_ffi["min"]["width"] = A.load.Int64(params + 32 + 8); 201 } 202 if (A.load.Bool(params + 56 + 16)) { 203 params_ffi["normal"] = {}; 204 params_ffi["normal"]["height"] = A.load.Int64(params + 56 + 0); 205 params_ffi["normal"]["width"] = A.load.Int64(params + 56 + 8); 206 } 207 208 const _ret = WEBEXT.guestViewInternal.setSize(instanceId, params_ffi); 209 A.store.Ref(retPtr, _ret); 210 }, 211 "try_SetSize": (retPtr: Pointer, errPtr: Pointer, instanceId: number, params: Pointer): heap.Ref<boolean> => { 212 try { 213 const params_ffi = {}; 214 215 if (A.load.Bool(params + 73)) { 216 params_ffi["enableAutoSize"] = A.load.Bool(params + 0); 217 } 218 if (A.load.Bool(params + 8 + 16)) { 219 params_ffi["max"] = {}; 220 params_ffi["max"]["height"] = A.load.Int64(params + 8 + 0); 221 params_ffi["max"]["width"] = A.load.Int64(params + 8 + 8); 222 } 223 if (A.load.Bool(params + 32 + 16)) { 224 params_ffi["min"] = {}; 225 params_ffi["min"]["height"] = A.load.Int64(params + 32 + 0); 226 params_ffi["min"]["width"] = A.load.Int64(params + 32 + 8); 227 } 228 if (A.load.Bool(params + 56 + 16)) { 229 params_ffi["normal"] = {}; 230 params_ffi["normal"]["height"] = A.load.Int64(params + 56 + 0); 231 params_ffi["normal"]["width"] = A.load.Int64(params + 56 + 8); 232 } 233 234 const _ret = WEBEXT.guestViewInternal.setSize(instanceId, params_ffi); 235 A.store.Ref(retPtr, _ret); 236 return A.H.TRUE; 237 } catch (err: any) { 238 A.store.Ref(errPtr, err); 239 return A.H.FALSE; 240 } 241 }, 242 }; 243 });