github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/enterprise/deviceattributes/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package deviceattributes 5 6 import ( 7 "github.com/primecitizens/pcz/std/core/abi" 8 "github.com/primecitizens/pcz/std/ffi/js" 9 "github.com/primecitizens/pcz/std/plat/js/webext/enterprise/deviceattributes/bindings" 10 ) 11 12 type GetDeviceAnnotatedLocationCallbackFunc func(this js.Ref, annotatedLocation js.String) js.Ref 13 14 func (fn GetDeviceAnnotatedLocationCallbackFunc) Register() js.Func[func(annotatedLocation js.String)] { 15 return js.RegisterCallback[func(annotatedLocation js.String)]( 16 fn, abi.FuncPCABIInternal(fn), 17 ) 18 } 19 20 func (fn GetDeviceAnnotatedLocationCallbackFunc) DispatchCallback( 21 targetPC uintptr, ctx *js.CallbackContext, 22 ) { 23 args := ctx.Args() 24 if len(args) != 1+1 /* js this */ || 25 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 26 js.ThrowInvalidCallbackInvocation() 27 } 28 29 if ctx.Return(fn( 30 args[0], 31 32 js.String{}.FromRef(args[0+1]), 33 )) { 34 return 35 } 36 37 js.ThrowCallbackValueNotReturned() 38 } 39 40 type GetDeviceAnnotatedLocationCallback[T any] struct { 41 Fn func(arg T, this js.Ref, annotatedLocation js.String) js.Ref 42 Arg T 43 } 44 45 func (cb *GetDeviceAnnotatedLocationCallback[T]) Register() js.Func[func(annotatedLocation js.String)] { 46 return js.RegisterCallback[func(annotatedLocation js.String)]( 47 cb, abi.FuncPCABIInternal(cb.Fn), 48 ) 49 } 50 51 func (cb *GetDeviceAnnotatedLocationCallback[T]) DispatchCallback( 52 targetPC uintptr, ctx *js.CallbackContext, 53 ) { 54 args := ctx.Args() 55 if len(args) != 1+1 /* js this */ || 56 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 57 js.ThrowInvalidCallbackInvocation() 58 } 59 60 if ctx.Return(cb.Fn( 61 cb.Arg, 62 args[0], 63 64 js.String{}.FromRef(args[0+1]), 65 )) { 66 return 67 } 68 69 js.ThrowCallbackValueNotReturned() 70 } 71 72 type GetDeviceAssetIdCallbackFunc func(this js.Ref, assetId js.String) js.Ref 73 74 func (fn GetDeviceAssetIdCallbackFunc) Register() js.Func[func(assetId js.String)] { 75 return js.RegisterCallback[func(assetId js.String)]( 76 fn, abi.FuncPCABIInternal(fn), 77 ) 78 } 79 80 func (fn GetDeviceAssetIdCallbackFunc) DispatchCallback( 81 targetPC uintptr, ctx *js.CallbackContext, 82 ) { 83 args := ctx.Args() 84 if len(args) != 1+1 /* js this */ || 85 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 86 js.ThrowInvalidCallbackInvocation() 87 } 88 89 if ctx.Return(fn( 90 args[0], 91 92 js.String{}.FromRef(args[0+1]), 93 )) { 94 return 95 } 96 97 js.ThrowCallbackValueNotReturned() 98 } 99 100 type GetDeviceAssetIdCallback[T any] struct { 101 Fn func(arg T, this js.Ref, assetId js.String) js.Ref 102 Arg T 103 } 104 105 func (cb *GetDeviceAssetIdCallback[T]) Register() js.Func[func(assetId js.String)] { 106 return js.RegisterCallback[func(assetId js.String)]( 107 cb, abi.FuncPCABIInternal(cb.Fn), 108 ) 109 } 110 111 func (cb *GetDeviceAssetIdCallback[T]) DispatchCallback( 112 targetPC uintptr, ctx *js.CallbackContext, 113 ) { 114 args := ctx.Args() 115 if len(args) != 1+1 /* js this */ || 116 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 117 js.ThrowInvalidCallbackInvocation() 118 } 119 120 if ctx.Return(cb.Fn( 121 cb.Arg, 122 args[0], 123 124 js.String{}.FromRef(args[0+1]), 125 )) { 126 return 127 } 128 129 js.ThrowCallbackValueNotReturned() 130 } 131 132 type GetDeviceHostnameCallbackFunc func(this js.Ref, hostname js.String) js.Ref 133 134 func (fn GetDeviceHostnameCallbackFunc) Register() js.Func[func(hostname js.String)] { 135 return js.RegisterCallback[func(hostname js.String)]( 136 fn, abi.FuncPCABIInternal(fn), 137 ) 138 } 139 140 func (fn GetDeviceHostnameCallbackFunc) DispatchCallback( 141 targetPC uintptr, ctx *js.CallbackContext, 142 ) { 143 args := ctx.Args() 144 if len(args) != 1+1 /* js this */ || 145 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 146 js.ThrowInvalidCallbackInvocation() 147 } 148 149 if ctx.Return(fn( 150 args[0], 151 152 js.String{}.FromRef(args[0+1]), 153 )) { 154 return 155 } 156 157 js.ThrowCallbackValueNotReturned() 158 } 159 160 type GetDeviceHostnameCallback[T any] struct { 161 Fn func(arg T, this js.Ref, hostname js.String) js.Ref 162 Arg T 163 } 164 165 func (cb *GetDeviceHostnameCallback[T]) Register() js.Func[func(hostname js.String)] { 166 return js.RegisterCallback[func(hostname js.String)]( 167 cb, abi.FuncPCABIInternal(cb.Fn), 168 ) 169 } 170 171 func (cb *GetDeviceHostnameCallback[T]) DispatchCallback( 172 targetPC uintptr, ctx *js.CallbackContext, 173 ) { 174 args := ctx.Args() 175 if len(args) != 1+1 /* js this */ || 176 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 177 js.ThrowInvalidCallbackInvocation() 178 } 179 180 if ctx.Return(cb.Fn( 181 cb.Arg, 182 args[0], 183 184 js.String{}.FromRef(args[0+1]), 185 )) { 186 return 187 } 188 189 js.ThrowCallbackValueNotReturned() 190 } 191 192 type GetDeviceSerialNumberCallbackFunc func(this js.Ref, serialNumber js.String) js.Ref 193 194 func (fn GetDeviceSerialNumberCallbackFunc) Register() js.Func[func(serialNumber js.String)] { 195 return js.RegisterCallback[func(serialNumber js.String)]( 196 fn, abi.FuncPCABIInternal(fn), 197 ) 198 } 199 200 func (fn GetDeviceSerialNumberCallbackFunc) DispatchCallback( 201 targetPC uintptr, ctx *js.CallbackContext, 202 ) { 203 args := ctx.Args() 204 if len(args) != 1+1 /* js this */ || 205 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 206 js.ThrowInvalidCallbackInvocation() 207 } 208 209 if ctx.Return(fn( 210 args[0], 211 212 js.String{}.FromRef(args[0+1]), 213 )) { 214 return 215 } 216 217 js.ThrowCallbackValueNotReturned() 218 } 219 220 type GetDeviceSerialNumberCallback[T any] struct { 221 Fn func(arg T, this js.Ref, serialNumber js.String) js.Ref 222 Arg T 223 } 224 225 func (cb *GetDeviceSerialNumberCallback[T]) Register() js.Func[func(serialNumber js.String)] { 226 return js.RegisterCallback[func(serialNumber js.String)]( 227 cb, abi.FuncPCABIInternal(cb.Fn), 228 ) 229 } 230 231 func (cb *GetDeviceSerialNumberCallback[T]) DispatchCallback( 232 targetPC uintptr, ctx *js.CallbackContext, 233 ) { 234 args := ctx.Args() 235 if len(args) != 1+1 /* js this */ || 236 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 237 js.ThrowInvalidCallbackInvocation() 238 } 239 240 if ctx.Return(cb.Fn( 241 cb.Arg, 242 args[0], 243 244 js.String{}.FromRef(args[0+1]), 245 )) { 246 return 247 } 248 249 js.ThrowCallbackValueNotReturned() 250 } 251 252 type GetDirectoryDeviceIdCallbackFunc func(this js.Ref, deviceId js.String) js.Ref 253 254 func (fn GetDirectoryDeviceIdCallbackFunc) Register() js.Func[func(deviceId js.String)] { 255 return js.RegisterCallback[func(deviceId js.String)]( 256 fn, abi.FuncPCABIInternal(fn), 257 ) 258 } 259 260 func (fn GetDirectoryDeviceIdCallbackFunc) DispatchCallback( 261 targetPC uintptr, ctx *js.CallbackContext, 262 ) { 263 args := ctx.Args() 264 if len(args) != 1+1 /* js this */ || 265 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 266 js.ThrowInvalidCallbackInvocation() 267 } 268 269 if ctx.Return(fn( 270 args[0], 271 272 js.String{}.FromRef(args[0+1]), 273 )) { 274 return 275 } 276 277 js.ThrowCallbackValueNotReturned() 278 } 279 280 type GetDirectoryDeviceIdCallback[T any] struct { 281 Fn func(arg T, this js.Ref, deviceId js.String) js.Ref 282 Arg T 283 } 284 285 func (cb *GetDirectoryDeviceIdCallback[T]) Register() js.Func[func(deviceId js.String)] { 286 return js.RegisterCallback[func(deviceId js.String)]( 287 cb, abi.FuncPCABIInternal(cb.Fn), 288 ) 289 } 290 291 func (cb *GetDirectoryDeviceIdCallback[T]) DispatchCallback( 292 targetPC uintptr, ctx *js.CallbackContext, 293 ) { 294 args := ctx.Args() 295 if len(args) != 1+1 /* js this */ || 296 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 297 js.ThrowInvalidCallbackInvocation() 298 } 299 300 if ctx.Return(cb.Fn( 301 cb.Arg, 302 args[0], 303 304 js.String{}.FromRef(args[0+1]), 305 )) { 306 return 307 } 308 309 js.ThrowCallbackValueNotReturned() 310 } 311 312 // HasFuncGetDeviceAnnotatedLocation returns true if the function "WEBEXT.enterprise.deviceAttributes.getDeviceAnnotatedLocation" exists. 313 func HasFuncGetDeviceAnnotatedLocation() bool { 314 return js.True == bindings.HasFuncGetDeviceAnnotatedLocation() 315 } 316 317 // FuncGetDeviceAnnotatedLocation returns the function "WEBEXT.enterprise.deviceAttributes.getDeviceAnnotatedLocation". 318 func FuncGetDeviceAnnotatedLocation() (fn js.Func[func() js.Promise[js.String]]) { 319 bindings.FuncGetDeviceAnnotatedLocation( 320 js.Pointer(&fn), 321 ) 322 return 323 } 324 325 // GetDeviceAnnotatedLocation calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceAnnotatedLocation" directly. 326 func GetDeviceAnnotatedLocation() (ret js.Promise[js.String]) { 327 bindings.CallGetDeviceAnnotatedLocation( 328 js.Pointer(&ret), 329 ) 330 331 return 332 } 333 334 // TryGetDeviceAnnotatedLocation calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceAnnotatedLocation" 335 // in a try/catch block and returns (_, err, ok = false) when it went through 336 // the catch clause. 337 func TryGetDeviceAnnotatedLocation() (ret js.Promise[js.String], exception js.Any, ok bool) { 338 ok = js.True == bindings.TryGetDeviceAnnotatedLocation( 339 js.Pointer(&ret), js.Pointer(&exception), 340 ) 341 342 return 343 } 344 345 // HasFuncGetDeviceAssetId returns true if the function "WEBEXT.enterprise.deviceAttributes.getDeviceAssetId" exists. 346 func HasFuncGetDeviceAssetId() bool { 347 return js.True == bindings.HasFuncGetDeviceAssetId() 348 } 349 350 // FuncGetDeviceAssetId returns the function "WEBEXT.enterprise.deviceAttributes.getDeviceAssetId". 351 func FuncGetDeviceAssetId() (fn js.Func[func() js.Promise[js.String]]) { 352 bindings.FuncGetDeviceAssetId( 353 js.Pointer(&fn), 354 ) 355 return 356 } 357 358 // GetDeviceAssetId calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceAssetId" directly. 359 func GetDeviceAssetId() (ret js.Promise[js.String]) { 360 bindings.CallGetDeviceAssetId( 361 js.Pointer(&ret), 362 ) 363 364 return 365 } 366 367 // TryGetDeviceAssetId calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceAssetId" 368 // in a try/catch block and returns (_, err, ok = false) when it went through 369 // the catch clause. 370 func TryGetDeviceAssetId() (ret js.Promise[js.String], exception js.Any, ok bool) { 371 ok = js.True == bindings.TryGetDeviceAssetId( 372 js.Pointer(&ret), js.Pointer(&exception), 373 ) 374 375 return 376 } 377 378 // HasFuncGetDeviceHostname returns true if the function "WEBEXT.enterprise.deviceAttributes.getDeviceHostname" exists. 379 func HasFuncGetDeviceHostname() bool { 380 return js.True == bindings.HasFuncGetDeviceHostname() 381 } 382 383 // FuncGetDeviceHostname returns the function "WEBEXT.enterprise.deviceAttributes.getDeviceHostname". 384 func FuncGetDeviceHostname() (fn js.Func[func() js.Promise[js.String]]) { 385 bindings.FuncGetDeviceHostname( 386 js.Pointer(&fn), 387 ) 388 return 389 } 390 391 // GetDeviceHostname calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceHostname" directly. 392 func GetDeviceHostname() (ret js.Promise[js.String]) { 393 bindings.CallGetDeviceHostname( 394 js.Pointer(&ret), 395 ) 396 397 return 398 } 399 400 // TryGetDeviceHostname calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceHostname" 401 // in a try/catch block and returns (_, err, ok = false) when it went through 402 // the catch clause. 403 func TryGetDeviceHostname() (ret js.Promise[js.String], exception js.Any, ok bool) { 404 ok = js.True == bindings.TryGetDeviceHostname( 405 js.Pointer(&ret), js.Pointer(&exception), 406 ) 407 408 return 409 } 410 411 // HasFuncGetDeviceSerialNumber returns true if the function "WEBEXT.enterprise.deviceAttributes.getDeviceSerialNumber" exists. 412 func HasFuncGetDeviceSerialNumber() bool { 413 return js.True == bindings.HasFuncGetDeviceSerialNumber() 414 } 415 416 // FuncGetDeviceSerialNumber returns the function "WEBEXT.enterprise.deviceAttributes.getDeviceSerialNumber". 417 func FuncGetDeviceSerialNumber() (fn js.Func[func() js.Promise[js.String]]) { 418 bindings.FuncGetDeviceSerialNumber( 419 js.Pointer(&fn), 420 ) 421 return 422 } 423 424 // GetDeviceSerialNumber calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceSerialNumber" directly. 425 func GetDeviceSerialNumber() (ret js.Promise[js.String]) { 426 bindings.CallGetDeviceSerialNumber( 427 js.Pointer(&ret), 428 ) 429 430 return 431 } 432 433 // TryGetDeviceSerialNumber calls the function "WEBEXT.enterprise.deviceAttributes.getDeviceSerialNumber" 434 // in a try/catch block and returns (_, err, ok = false) when it went through 435 // the catch clause. 436 func TryGetDeviceSerialNumber() (ret js.Promise[js.String], exception js.Any, ok bool) { 437 ok = js.True == bindings.TryGetDeviceSerialNumber( 438 js.Pointer(&ret), js.Pointer(&exception), 439 ) 440 441 return 442 } 443 444 // HasFuncGetDirectoryDeviceId returns true if the function "WEBEXT.enterprise.deviceAttributes.getDirectoryDeviceId" exists. 445 func HasFuncGetDirectoryDeviceId() bool { 446 return js.True == bindings.HasFuncGetDirectoryDeviceId() 447 } 448 449 // FuncGetDirectoryDeviceId returns the function "WEBEXT.enterprise.deviceAttributes.getDirectoryDeviceId". 450 func FuncGetDirectoryDeviceId() (fn js.Func[func() js.Promise[js.String]]) { 451 bindings.FuncGetDirectoryDeviceId( 452 js.Pointer(&fn), 453 ) 454 return 455 } 456 457 // GetDirectoryDeviceId calls the function "WEBEXT.enterprise.deviceAttributes.getDirectoryDeviceId" directly. 458 func GetDirectoryDeviceId() (ret js.Promise[js.String]) { 459 bindings.CallGetDirectoryDeviceId( 460 js.Pointer(&ret), 461 ) 462 463 return 464 } 465 466 // TryGetDirectoryDeviceId calls the function "WEBEXT.enterprise.deviceAttributes.getDirectoryDeviceId" 467 // in a try/catch block and returns (_, err, ok = false) when it went through 468 // the catch clause. 469 func TryGetDirectoryDeviceId() (ret js.Promise[js.String], exception js.Any, ok bool) { 470 ok = js.True == bindings.TryGetDirectoryDeviceId( 471 js.Pointer(&ret), js.Pointer(&exception), 472 ) 473 474 return 475 }