1 module libwasm.bindings.IDBFactory; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.IDBOpenDBRequest; 7 import libwasm.bindings.StorageType; 8 9 @safe: 10 nothrow: 11 12 struct IDBFactory { 13 nothrow: 14 JsHandle handle; 15 alias handle this; 16 this(Handle h) { 17 this.handle = JsHandle(h); 18 } 19 auto open()(string name, uint version_) { 20 return IDBOpenDBRequest(Object_Call_string_uint__Handle(this.handle, "open", name, version_)); 21 } 22 auto open()(string name, scope ref IDBOpenDBOptions options) { 23 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "open", "string;Handle", tuple(name, cast(Handle)options.handle))); 24 } 25 auto open()(string name) { 26 return IDBOpenDBRequest(Object_Call_string__Handle(this.handle, "open", name)); 27 } 28 auto deleteDatabase()(string name, scope ref IDBOpenDBOptions options) { 29 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "deleteDatabase", "string;Handle", tuple(name, cast(Handle)options.handle))); 30 } 31 auto deleteDatabase()(string name) { 32 return IDBOpenDBRequest(Object_Call_string__Handle(this.handle, "deleteDatabase", name)); 33 } 34 short cmp(T0, T1)(scope auto ref T0 first, scope auto ref T1 second) { 35 // Any 36 Handle _handle_first = getOrCreateHandle(first); 37 // Any 38 Handle _handle_second = getOrCreateHandle(second); 39 auto result = Serialize_Object_VarArgCall!short(this.handle, "cmp", "Handle;Handle", tuple(_handle_first, _handle_second)); 40 dropHandle!(T0)(_handle_first); 41 dropHandle!(T1)(_handle_second); 42 return result; 43 } 44 auto openForPrincipal()(scope ref Principal principal, string name, uint version_) { 45 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "openForPrincipal", "Handle;string;uint", tuple(cast(Handle)principal.handle, name, version_))); 46 } 47 auto openForPrincipal()(scope ref Principal principal, string name, scope ref IDBOpenDBOptions options) { 48 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "openForPrincipal", "Handle;string;Handle", tuple(cast(Handle)principal.handle, name, cast(Handle)options.handle))); 49 } 50 auto openForPrincipal()(scope ref Principal principal, string name) { 51 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "openForPrincipal", "Handle;string", tuple(cast(Handle)principal.handle, name))); 52 } 53 auto deleteForPrincipal()(scope ref Principal principal, string name, scope ref IDBOpenDBOptions options) { 54 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "deleteForPrincipal", "Handle;string;Handle", tuple(cast(Handle)principal.handle, name, cast(Handle)options.handle))); 55 } 56 auto deleteForPrincipal()(scope ref Principal principal, string name) { 57 return IDBOpenDBRequest(Serialize_Object_VarArgCall!Handle(this.handle, "deleteForPrincipal", "Handle;string", tuple(cast(Handle)principal.handle, name))); 58 } 59 } 60 struct IDBOpenDBOptions { 61 nothrow: 62 JsHandle handle; 63 alias handle this; 64 this(Handle h) { 65 this.handle = JsHandle(h); 66 } 67 static auto create() { 68 return IDBOpenDBOptions(libwasm_add__object()); 69 } 70 void version_()(uint version_) { 71 Object_Call_uint__void(this.handle, "version", version_); 72 } 73 uint version_()() { 74 return Object_Getter__uint(this.handle, "version"); 75 } 76 void storage()(StorageType storage) { 77 Object_Call_int__void(this.handle, "storage", storage); 78 } 79 StorageType storage()() { 80 return Object_Getter__int(this.handle, "storage"); 81 } 82 } 83 84