github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/instanceid/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/instanceid", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_DeleteTokenArgDeleteTokenParams": (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 + 8, false); 12 A.store.Ref(ptr + 0, undefined); 13 A.store.Ref(ptr + 4, undefined); 14 } else { 15 A.store.Bool(ptr + 8, true); 16 A.store.Ref(ptr + 0, x["authorizedEntity"]); 17 A.store.Ref(ptr + 4, x["scope"]); 18 } 19 }, 20 "load_DeleteTokenArgDeleteTokenParams": ( 21 ptr: Pointer, 22 create: heap.Ref<boolean>, 23 ref: heap.Ref<any> 24 ): heap.Ref<any> => { 25 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 26 27 x["authorizedEntity"] = A.load.Ref(ptr + 0, undefined); 28 x["scope"] = A.load.Ref(ptr + 4, undefined); 29 return create === A.H.TRUE ? A.H.push(x) : ref; 30 }, 31 32 "store_GetTokenArgGetTokenParams": (ptr: Pointer, ref: heap.Ref<any>) => { 33 const x = A.H.get<any>(ref); 34 35 if (typeof x === "undefined") { 36 A.store.Bool(ptr + 12, false); 37 A.store.Ref(ptr + 0, undefined); 38 A.store.Ref(ptr + 4, undefined); 39 A.store.Ref(ptr + 8, undefined); 40 } else { 41 A.store.Bool(ptr + 12, true); 42 A.store.Ref(ptr + 0, x["authorizedEntity"]); 43 A.store.Ref(ptr + 4, x["options"]); 44 A.store.Ref(ptr + 8, x["scope"]); 45 } 46 }, 47 "load_GetTokenArgGetTokenParams": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 48 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 49 50 x["authorizedEntity"] = A.load.Ref(ptr + 0, undefined); 51 x["options"] = A.load.Ref(ptr + 4, undefined); 52 x["scope"] = A.load.Ref(ptr + 8, undefined); 53 return create === A.H.TRUE ? A.H.push(x) : ref; 54 }, 55 "has_DeleteID": (): heap.Ref<boolean> => { 56 if (WEBEXT?.instanceID && "deleteID" in WEBEXT?.instanceID) { 57 return A.H.TRUE; 58 } 59 return A.H.FALSE; 60 }, 61 "func_DeleteID": (fn: Pointer): void => { 62 A.store.Ref(fn, WEBEXT.instanceID.deleteID); 63 }, 64 "call_DeleteID": (retPtr: Pointer): void => { 65 const _ret = WEBEXT.instanceID.deleteID(); 66 A.store.Ref(retPtr, _ret); 67 }, 68 "try_DeleteID": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 69 try { 70 const _ret = WEBEXT.instanceID.deleteID(); 71 A.store.Ref(retPtr, _ret); 72 return A.H.TRUE; 73 } catch (err: any) { 74 A.store.Ref(errPtr, err); 75 return A.H.FALSE; 76 } 77 }, 78 "has_DeleteToken": (): heap.Ref<boolean> => { 79 if (WEBEXT?.instanceID && "deleteToken" in WEBEXT?.instanceID) { 80 return A.H.TRUE; 81 } 82 return A.H.FALSE; 83 }, 84 "func_DeleteToken": (fn: Pointer): void => { 85 A.store.Ref(fn, WEBEXT.instanceID.deleteToken); 86 }, 87 "call_DeleteToken": (retPtr: Pointer, deleteTokenParams: Pointer): void => { 88 const deleteTokenParams_ffi = {}; 89 90 deleteTokenParams_ffi["authorizedEntity"] = A.load.Ref(deleteTokenParams + 0, undefined); 91 deleteTokenParams_ffi["scope"] = A.load.Ref(deleteTokenParams + 4, undefined); 92 93 const _ret = WEBEXT.instanceID.deleteToken(deleteTokenParams_ffi); 94 A.store.Ref(retPtr, _ret); 95 }, 96 "try_DeleteToken": (retPtr: Pointer, errPtr: Pointer, deleteTokenParams: Pointer): heap.Ref<boolean> => { 97 try { 98 const deleteTokenParams_ffi = {}; 99 100 deleteTokenParams_ffi["authorizedEntity"] = A.load.Ref(deleteTokenParams + 0, undefined); 101 deleteTokenParams_ffi["scope"] = A.load.Ref(deleteTokenParams + 4, undefined); 102 103 const _ret = WEBEXT.instanceID.deleteToken(deleteTokenParams_ffi); 104 A.store.Ref(retPtr, _ret); 105 return A.H.TRUE; 106 } catch (err: any) { 107 A.store.Ref(errPtr, err); 108 return A.H.FALSE; 109 } 110 }, 111 "has_GetCreationTime": (): heap.Ref<boolean> => { 112 if (WEBEXT?.instanceID && "getCreationTime" in WEBEXT?.instanceID) { 113 return A.H.TRUE; 114 } 115 return A.H.FALSE; 116 }, 117 "func_GetCreationTime": (fn: Pointer): void => { 118 A.store.Ref(fn, WEBEXT.instanceID.getCreationTime); 119 }, 120 "call_GetCreationTime": (retPtr: Pointer): void => { 121 const _ret = WEBEXT.instanceID.getCreationTime(); 122 A.store.Ref(retPtr, _ret); 123 }, 124 "try_GetCreationTime": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 125 try { 126 const _ret = WEBEXT.instanceID.getCreationTime(); 127 A.store.Ref(retPtr, _ret); 128 return A.H.TRUE; 129 } catch (err: any) { 130 A.store.Ref(errPtr, err); 131 return A.H.FALSE; 132 } 133 }, 134 "has_GetID": (): heap.Ref<boolean> => { 135 if (WEBEXT?.instanceID && "getID" in WEBEXT?.instanceID) { 136 return A.H.TRUE; 137 } 138 return A.H.FALSE; 139 }, 140 "func_GetID": (fn: Pointer): void => { 141 A.store.Ref(fn, WEBEXT.instanceID.getID); 142 }, 143 "call_GetID": (retPtr: Pointer): void => { 144 const _ret = WEBEXT.instanceID.getID(); 145 A.store.Ref(retPtr, _ret); 146 }, 147 "try_GetID": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 148 try { 149 const _ret = WEBEXT.instanceID.getID(); 150 A.store.Ref(retPtr, _ret); 151 return A.H.TRUE; 152 } catch (err: any) { 153 A.store.Ref(errPtr, err); 154 return A.H.FALSE; 155 } 156 }, 157 "has_GetToken": (): heap.Ref<boolean> => { 158 if (WEBEXT?.instanceID && "getToken" in WEBEXT?.instanceID) { 159 return A.H.TRUE; 160 } 161 return A.H.FALSE; 162 }, 163 "func_GetToken": (fn: Pointer): void => { 164 A.store.Ref(fn, WEBEXT.instanceID.getToken); 165 }, 166 "call_GetToken": (retPtr: Pointer, getTokenParams: Pointer): void => { 167 const getTokenParams_ffi = {}; 168 169 getTokenParams_ffi["authorizedEntity"] = A.load.Ref(getTokenParams + 0, undefined); 170 getTokenParams_ffi["options"] = A.load.Ref(getTokenParams + 4, undefined); 171 getTokenParams_ffi["scope"] = A.load.Ref(getTokenParams + 8, undefined); 172 173 const _ret = WEBEXT.instanceID.getToken(getTokenParams_ffi); 174 A.store.Ref(retPtr, _ret); 175 }, 176 "try_GetToken": (retPtr: Pointer, errPtr: Pointer, getTokenParams: Pointer): heap.Ref<boolean> => { 177 try { 178 const getTokenParams_ffi = {}; 179 180 getTokenParams_ffi["authorizedEntity"] = A.load.Ref(getTokenParams + 0, undefined); 181 getTokenParams_ffi["options"] = A.load.Ref(getTokenParams + 4, undefined); 182 getTokenParams_ffi["scope"] = A.load.Ref(getTokenParams + 8, undefined); 183 184 const _ret = WEBEXT.instanceID.getToken(getTokenParams_ffi); 185 A.store.Ref(retPtr, _ret); 186 return A.H.TRUE; 187 } catch (err: any) { 188 A.store.Ref(errPtr, err); 189 return A.H.FALSE; 190 } 191 }, 192 "has_OnTokenRefresh": (): heap.Ref<boolean> => { 193 if (WEBEXT?.instanceID?.onTokenRefresh && "addListener" in WEBEXT?.instanceID?.onTokenRefresh) { 194 return A.H.TRUE; 195 } 196 return A.H.FALSE; 197 }, 198 "func_OnTokenRefresh": (fn: Pointer): void => { 199 A.store.Ref(fn, WEBEXT.instanceID.onTokenRefresh.addListener); 200 }, 201 "call_OnTokenRefresh": (retPtr: Pointer, callback: heap.Ref<object>): void => { 202 const _ret = WEBEXT.instanceID.onTokenRefresh.addListener(A.H.get<object>(callback)); 203 }, 204 "try_OnTokenRefresh": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 205 try { 206 const _ret = WEBEXT.instanceID.onTokenRefresh.addListener(A.H.get<object>(callback)); 207 return A.H.TRUE; 208 } catch (err: any) { 209 A.store.Ref(errPtr, err); 210 return A.H.FALSE; 211 } 212 }, 213 "has_OffTokenRefresh": (): heap.Ref<boolean> => { 214 if (WEBEXT?.instanceID?.onTokenRefresh && "removeListener" in WEBEXT?.instanceID?.onTokenRefresh) { 215 return A.H.TRUE; 216 } 217 return A.H.FALSE; 218 }, 219 "func_OffTokenRefresh": (fn: Pointer): void => { 220 A.store.Ref(fn, WEBEXT.instanceID.onTokenRefresh.removeListener); 221 }, 222 "call_OffTokenRefresh": (retPtr: Pointer, callback: heap.Ref<object>): void => { 223 const _ret = WEBEXT.instanceID.onTokenRefresh.removeListener(A.H.get<object>(callback)); 224 }, 225 "try_OffTokenRefresh": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 226 try { 227 const _ret = WEBEXT.instanceID.onTokenRefresh.removeListener(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_HasOnTokenRefresh": (): heap.Ref<boolean> => { 235 if (WEBEXT?.instanceID?.onTokenRefresh && "hasListener" in WEBEXT?.instanceID?.onTokenRefresh) { 236 return A.H.TRUE; 237 } 238 return A.H.FALSE; 239 }, 240 "func_HasOnTokenRefresh": (fn: Pointer): void => { 241 A.store.Ref(fn, WEBEXT.instanceID.onTokenRefresh.hasListener); 242 }, 243 "call_HasOnTokenRefresh": (retPtr: Pointer, callback: heap.Ref<object>): void => { 244 const _ret = WEBEXT.instanceID.onTokenRefresh.hasListener(A.H.get<object>(callback)); 245 A.store.Bool(retPtr, _ret); 246 }, 247 "try_HasOnTokenRefresh": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 248 try { 249 const _ret = WEBEXT.instanceID.onTokenRefresh.hasListener(A.H.get<object>(callback)); 250 A.store.Bool(retPtr, _ret); 251 return A.H.TRUE; 252 } catch (err: any) { 253 A.store.Ref(errPtr, err); 254 return A.H.FALSE; 255 } 256 }, 257 }; 258 });