1 module spasm.bindings.encoding;
2 
3 import spasm.types;
4 import spasm.bindings.common;
5 import spasm.bindings.streams;
6 
7 @safe:
8 nothrow:
9 
10 struct TextDecodeOptions {
11   nothrow:
12   JsHandle handle;
13   alias handle this;
14   this(Handle h) {
15     this.handle = JsHandle(h);
16   }
17   static auto create() {
18     return TextDecodeOptions(spasm_add__object());
19   }
20   void stream()(bool stream) {
21     TextDecodeOptions_stream_Set(this.handle, stream);
22   }
23   auto stream()() {
24     return TextDecodeOptions_stream_Get(this.handle);
25   }
26 }
27 struct TextDecoder {
28   nothrow:
29   JsHandle handle;
30   alias handle this;
31   this(Handle h) {
32     this.handle = JsHandle(h);
33   }
34   auto decode()(scope ref BufferSource input, scope ref TextDecodeOptions options) {
35     return TextDecoder_decode(this.handle, input, options.handle);
36   }
37   auto decode()(scope ref BufferSource input) {
38     return TextDecoder_decode_0(this.handle, input);
39   }
40   auto decode()() {
41     return TextDecoder_decode_1(this.handle);
42   }
43   auto encoding()() {
44     return TextDecoderCommon_encoding_Get(this.handle);
45   }
46   auto fatal()() {
47     return TextDecoderCommon_fatal_Get(this.handle);
48   }
49   auto ignoreBOM()() {
50     return TextDecoderCommon_ignoreBOM_Get(this.handle);
51   }
52 }
53 struct TextDecoderOptions {
54   nothrow:
55   JsHandle handle;
56   alias handle this;
57   this(Handle h) {
58     this.handle = JsHandle(h);
59   }
60   static auto create() {
61     return TextDecoderOptions(spasm_add__object());
62   }
63   void fatal()(bool fatal) {
64     TextDecoderOptions_fatal_Set(this.handle, fatal);
65   }
66   auto fatal()() {
67     return TextDecoderOptions_fatal_Get(this.handle);
68   }
69   void ignoreBOM()(bool ignoreBOM) {
70     TextDecoderOptions_ignoreBOM_Set(this.handle, ignoreBOM);
71   }
72   auto ignoreBOM()() {
73     return TextDecoderOptions_ignoreBOM_Get(this.handle);
74   }
75 }
76 struct TextDecoderStream {
77   nothrow:
78   JsHandle handle;
79   alias handle this;
80   this(Handle h) {
81     this.handle = JsHandle(h);
82   }
83   auto encoding()() {
84     return TextDecoderCommon_encoding_Get(this.handle);
85   }
86   auto fatal()() {
87     return TextDecoderCommon_fatal_Get(this.handle);
88   }
89   auto ignoreBOM()() {
90     return TextDecoderCommon_ignoreBOM_Get(this.handle);
91   }
92   auto readable()() {
93     return ReadableStream(GenericTransformStream_readable_Get(this.handle));
94   }
95   auto writable()() {
96     return WritableStream(GenericTransformStream_writable_Get(this.handle));
97   }
98 }
99 struct TextEncoder {
100   nothrow:
101   JsHandle handle;
102   alias handle this;
103   this(Handle h) {
104     this.handle = JsHandle(h);
105   }
106   auto encode()(string input /* = "" */) {
107     return Uint8Array(TextEncoder_encode(this.handle, input));
108   }
109   auto encode()() {
110     return Uint8Array(TextEncoder_encode_0(this.handle));
111   }
112   auto encoding()() {
113     return TextEncoderCommon_encoding_Get(this.handle);
114   }
115 }
116 struct TextEncoderStream {
117   nothrow:
118   JsHandle handle;
119   alias handle this;
120   this(Handle h) {
121     this.handle = JsHandle(h);
122   }
123   auto encoding()() {
124     return TextEncoderCommon_encoding_Get(this.handle);
125   }
126   auto readable()() {
127     return ReadableStream(GenericTransformStream_readable_Get(this.handle));
128   }
129   auto writable()() {
130     return WritableStream(GenericTransformStream_writable_Get(this.handle));
131   }
132 }
133 
134 
135 extern (C) Handle GenericTransformStream_readable_Get(Handle);
136 extern (C) Handle GenericTransformStream_writable_Get(Handle);
137 extern (C) void TextDecodeOptions_stream_Set(Handle, bool);
138 extern (C) bool TextDecodeOptions_stream_Get(Handle);
139 extern (C) string TextDecoder_decode(Handle, scope ref BufferSource, Handle);
140 extern (C) string TextDecoder_decode_0(Handle, scope ref BufferSource);
141 extern (C) string TextDecoder_decode_1(Handle);
142 extern (C) string TextDecoderCommon_encoding_Get(Handle);
143 extern (C) bool TextDecoderCommon_fatal_Get(Handle);
144 extern (C) bool TextDecoderCommon_ignoreBOM_Get(Handle);
145 extern (C) void TextDecoderOptions_fatal_Set(Handle, bool);
146 extern (C) bool TextDecoderOptions_fatal_Get(Handle);
147 extern (C) void TextDecoderOptions_ignoreBOM_Set(Handle, bool);
148 extern (C) bool TextDecoderOptions_ignoreBOM_Get(Handle);
149 extern (C) Handle TextEncoder_encode(Handle, string);
150 extern (C) Handle TextEncoder_encode_0(Handle);
151 extern (C) string TextEncoderCommon_encoding_Get(Handle);