1 module libwasm.bindings.IterableIterator;
2 
3 import libwasm.types;
4 
5 import memutils.ct: tuple;
6 @safe:
7 nothrow:
8 
9 struct IterableKeyAndValueResult {
10   nothrow:
11   JsHandle handle;
12   alias handle this;
13   this(Handle h) {
14     this.handle = JsHandle(h);
15   }
16   static auto create() {
17     return IterableKeyAndValueResult(libwasm_add__object());
18   }
19   void value()(scope ref Sequence!(Any) value) {
20     Object_Call_Handle__void(this.handle, "value", value.handle);
21   }
22   auto value()() {
23     return Sequence!(Any)(Object_Getter__Handle(this.handle, "value"));
24   }
25   void done()(bool done) {
26     Object_Call_bool__void(this.handle, "done", done);
27   }
28   bool done()() {
29     return Object_Getter__bool(this.handle, "done");
30   }
31 }
32 struct IterableKeyOrValueResult {
33   nothrow:
34   JsHandle handle;
35   alias handle this;
36   this(Handle h) {
37     this.handle = JsHandle(h);
38   }
39   static auto create() {
40     return IterableKeyOrValueResult(libwasm_add__object());
41   }
42   void value(T0)(scope auto ref T0 value) {
43     import std.traits : isNumeric, isFloatingPoint, isSomeString;
44     if (isSomeString!T0) {
45       Object_Call_string__void(this.handle, "value", cast(string) value);
46       return;
47     } else if (isNumeric!T0 && !isFloatingPoint!T0) {
48       Object_Call_long__void(this.handle, "value", cast(long) value);
49       return;
50     } else if (isFloatingPoint!T0) {
51       Object_Call_double__void(this.handle, "value", cast(double) value);
52       return;
53     }
54     // Any
55     Handle _handle_value = getOrCreateHandle(value);
56     Object_Call_Handle__void(this.handle, "value", _handle_value);
57     dropHandle!(T0)(_handle_value);
58   }
59   auto value()() {
60     return Any(Object_Getter__Handle(this.handle, "value"));
61   }
62   void done()(bool done) {
63     Object_Call_bool__void(this.handle, "done", done);
64   }
65   bool done()() {
66     return Object_Getter__bool(this.handle, "done");
67   }
68 }
69 
70