1 module libwasm.bindings.Geolocation; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.Position; 7 import libwasm.bindings.PositionError; 8 9 @safe: 10 nothrow: 11 12 struct Geolocation { 13 nothrow: 14 JsHandle handle; 15 alias handle this; 16 this(Handle h) { 17 this.handle = JsHandle(h); 18 } 19 void getCurrentPosition(T1)(PositionCallback successCallback, scope auto ref Optional!(T1) errorCallback /* = no!(PositionErrorCallback) */, scope ref PositionOptions options) if (isTOrPointer!(T1, PositionErrorCallback)) { 20 Geolocation_getCurrentPosition(this.handle, successCallback, !errorCallback.empty, errorCallback.front, options.handle); 21 } 22 void getCurrentPosition(T1)(PositionCallback successCallback, scope auto ref Optional!(T1) errorCallback /* = no!(PositionErrorCallback) */) if (isTOrPointer!(T1, PositionErrorCallback)) { 23 Geolocation_getCurrentPosition_0(this.handle, successCallback, !errorCallback.empty, errorCallback.front); 24 } 25 void getCurrentPosition()(PositionCallback successCallback) { 26 Geolocation_getCurrentPosition_1(this.handle, successCallback); 27 } 28 int watchPosition(T1)(PositionCallback successCallback, scope auto ref Optional!(T1) errorCallback /* = no!(PositionErrorCallback) */, scope ref PositionOptions options) if (isTOrPointer!(T1, PositionErrorCallback)) { 29 return Geolocation_watchPosition(this.handle, successCallback, !errorCallback.empty, errorCallback.front, options.handle); 30 } 31 int watchPosition(T1)(PositionCallback successCallback, scope auto ref Optional!(T1) errorCallback /* = no!(PositionErrorCallback) */) if (isTOrPointer!(T1, PositionErrorCallback)) { 32 return Geolocation_watchPosition_0(this.handle, successCallback, !errorCallback.empty, errorCallback.front); 33 } 34 int watchPosition()(PositionCallback successCallback) { 35 return Geolocation_watchPosition_1(this.handle, successCallback); 36 } 37 void clearWatch()(int watchId) { 38 Object_Call_int__void(this.handle, "clearWatch", watchId); 39 } 40 } 41 alias PositionCallback = void delegate(Position); 42 alias PositionErrorCallback = void delegate(PositionError); 43 struct PositionOptions { 44 nothrow: 45 JsHandle handle; 46 alias handle this; 47 this(Handle h) { 48 this.handle = JsHandle(h); 49 } 50 static auto create() { 51 return PositionOptions(libwasm_add__object()); 52 } 53 void enableHighAccuracy()(bool enableHighAccuracy) { 54 Object_Call_bool__void(this.handle, "enableHighAccuracy", enableHighAccuracy); 55 } 56 bool enableHighAccuracy()() { 57 return Object_Getter__bool(this.handle, "enableHighAccuracy"); 58 } 59 void timeout()(uint timeout) { 60 Object_Call_uint__void(this.handle, "timeout", timeout); 61 } 62 uint timeout()() { 63 return Object_Getter__uint(this.handle, "timeout"); 64 } 65 void maximumAge()(uint maximumAge) { 66 Object_Call_uint__void(this.handle, "maximumAge", maximumAge); 67 } 68 uint maximumAge()() { 69 return Object_Getter__uint(this.handle, "maximumAge"); 70 } 71 } 72 73 74 extern (C) void Geolocation_getCurrentPosition(Handle, PositionCallback, bool, PositionErrorCallback, Handle); 75 extern (C) void Geolocation_getCurrentPosition_0(Handle, PositionCallback, bool, PositionErrorCallback); 76 extern (C) void Geolocation_getCurrentPosition_1(Handle, PositionCallback); 77 extern (C) int Geolocation_watchPosition(Handle, PositionCallback, bool, PositionErrorCallback, Handle); 78 extern (C) int Geolocation_watchPosition_0(Handle, PositionCallback, bool, PositionErrorCallback); 79 extern (C) int Geolocation_watchPosition_1(Handle, PositionCallback);