@@ -19,7 +19,8 @@ namespace ccf::js::extensions::kvhelpers
1919 static JSValue C_FUNC_NAME ( \
2020 JSContext* ctx, JSValueConst this_val, int , JSValueConst*) \
2121 { \
22- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx); \
22+ js::core::Context& jsctx = \
23+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx)); \
2324 const auto table_name = \
2425 jsctx.to_str (JS_GetPropertyStr (jsctx, this_val, " _map_name" )) \
2526 .value_or (" " ); \
@@ -66,23 +67,24 @@ namespace ccf::js::extensions::kvhelpers
6667 static JSValue js_kv_map_has (
6768 JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
6869 {
69- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
70+ js::core::Context& jsctx =
71+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
7072
7173 if (argc != 1 )
7274 {
7375 return JS_ThrowTypeError (
7476 ctx, " Passed %d arguments, but expected 1" , argc);
7577 }
7678
77- size_t key_size;
79+ size_t key_size = 0 ;
7880 uint8_t * key = JS_GetArrayBuffer (ctx, &key_size, argv[0 ]);
7981
8082 if (!key)
8183 {
8284 return JS_ThrowTypeError (ctx, " Argument must be an ArrayBuffer" );
8385 }
8486
85- auto handle = GetReadOnlyHandle (jsctx, this_val);
87+ auto * handle = GetReadOnlyHandle (jsctx, this_val);
8688 JS_CHECK_HANDLE (handle);
8789
8890 auto has = handle->has ({key, key + key_size});
@@ -94,23 +96,24 @@ namespace ccf::js::extensions::kvhelpers
9496 static JSValue js_kv_map_get (
9597 JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
9698 {
97- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
99+ js::core::Context& jsctx =
100+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
98101
99102 if (argc != 1 )
100103 {
101104 return JS_ThrowTypeError (
102105 ctx, " Passed %d arguments, but expected 1" , argc);
103106 }
104107
105- size_t key_size;
108+ size_t key_size = 0 ;
106109 uint8_t * key = JS_GetArrayBuffer (ctx, &key_size, argv[0 ]);
107110
108111 if (!key)
109112 {
110113 return JS_ThrowTypeError (ctx, " Argument must be an ArrayBuffer" );
111114 }
112115
113- auto handle = GetReadOnlyHandle (jsctx, this_val);
116+ auto * handle = GetReadOnlyHandle (jsctx, this_val);
114117 JS_CHECK_HANDLE (handle);
115118
116119 auto val = handle->get ({key, key + key_size});
@@ -131,23 +134,24 @@ namespace ccf::js::extensions::kvhelpers
131134 static JSValue js_kv_get_version_of_previous_write (
132135 JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
133136 {
134- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
137+ js::core::Context& jsctx =
138+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
135139
136140 if (argc != 1 )
137141 {
138142 return JS_ThrowTypeError (
139143 ctx, " Passed %d arguments, but expected 1" , argc);
140144 }
141145
142- size_t key_size;
146+ size_t key_size = 0 ;
143147 uint8_t * key = JS_GetArrayBuffer (ctx, &key_size, argv[0 ]);
144148
145149 if (!key)
146150 {
147151 return JS_ThrowTypeError (ctx, " Argument must be an ArrayBuffer" );
148152 }
149153
150- auto handle = GetReadOnlyHandle (jsctx, this_val);
154+ auto * handle = GetReadOnlyHandle (jsctx, this_val);
151155 JS_CHECK_HANDLE (handle);
152156
153157 auto val = handle->get_version_of_previous_write ({key, key + key_size});
@@ -162,11 +166,12 @@ namespace ccf::js::extensions::kvhelpers
162166
163167 template <ROHandleGetter GetReadOnlyHandle>
164168 static JSValue js_kv_map_size_getter (
165- JSContext* ctx, JSValueConst this_val, int argc, JSValueConst*)
169+ JSContext* ctx, JSValueConst this_val, int /* argc*/ , JSValueConst*)
166170 {
167- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
171+ js::core::Context& jsctx =
172+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
168173
169- auto handle = GetReadOnlyHandle (jsctx, this_val);
174+ auto * handle = GetReadOnlyHandle (jsctx, this_val);
170175 JS_CHECK_HANDLE (handle);
171176
172177 const uint64_t size = handle->size ();
@@ -183,23 +188,24 @@ namespace ccf::js::extensions::kvhelpers
183188 static JSValue js_kv_map_delete (
184189 JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
185190 {
186- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
191+ js::core::Context& jsctx =
192+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
187193
188194 if (argc != 1 )
189195 {
190196 return JS_ThrowTypeError (
191197 ctx, " Passed %d arguments, but expected 1" , argc);
192198 }
193199
194- size_t key_size;
200+ size_t key_size = 0 ;
195201 uint8_t * key = JS_GetArrayBuffer (ctx, &key_size, argv[0 ]);
196202
197203 if (!key)
198204 {
199205 return JS_ThrowTypeError (ctx, " Argument must be an ArrayBuffer" );
200206 }
201207
202- auto handle = GetWriteHandle (jsctx, this_val);
208+ auto * handle = GetWriteHandle (jsctx, this_val);
203209 JS_CHECK_HANDLE (handle);
204210
205211 handle->remove ({key, key + key_size});
@@ -211,26 +217,27 @@ namespace ccf::js::extensions::kvhelpers
211217 static JSValue js_kv_map_set (
212218 JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
213219 {
214- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
220+ js::core::Context& jsctx =
221+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
215222
216223 if (argc != 2 )
217224 {
218225 return JS_ThrowTypeError (
219226 ctx, " Passed %d arguments, but expected 2" , argc);
220227 }
221228
222- size_t key_size;
229+ size_t key_size = 0 ;
223230 uint8_t * key = JS_GetArrayBuffer (ctx, &key_size, argv[0 ]);
224231
225- size_t val_size;
232+ size_t val_size = 0 ;
226233 uint8_t * val = JS_GetArrayBuffer (ctx, &val_size, argv[1 ]);
227234
228235 if (!key || !val)
229236 {
230237 return JS_ThrowTypeError (ctx, " Arguments must be ArrayBuffers" );
231238 }
232239
233- auto handle = GetWriteHandle (jsctx, this_val);
240+ auto * handle = GetWriteHandle (jsctx, this_val);
234241 JS_CHECK_HANDLE (handle);
235242
236243 handle->put ({key, key + key_size}, {val, val + val_size});
@@ -240,17 +247,18 @@ namespace ccf::js::extensions::kvhelpers
240247
241248 template <RWHandleGetter GetWriteHandle>
242249 static JSValue js_kv_map_clear (
243- JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
250+ JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* /* argv*/ )
244251 {
245- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
252+ js::core::Context& jsctx =
253+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
246254
247255 if (argc != 0 )
248256 {
249257 return JS_ThrowTypeError (
250258 ctx, " Passed %d arguments, but expected 0" , argc);
251259 }
252260
253- auto handle = GetWriteHandle (jsctx, this_val);
261+ auto * handle = GetWriteHandle (jsctx, this_val);
254262 JS_CHECK_HANDLE (handle);
255263
256264 handle->clear ();
@@ -262,11 +270,14 @@ namespace ccf::js::extensions::kvhelpers
262270 static JSValue js_kv_map_foreach (
263271 JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
264272 {
265- js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque (ctx);
273+ js::core::Context& jsctx =
274+ *static_cast <js::core::Context*>(JS_GetContextOpaque (ctx));
266275
267276 if (argc != 1 )
277+ {
268278 return JS_ThrowTypeError (
269279 ctx, " Passed %d arguments, but expected 1" , argc);
280+ }
270281
271282 js::core::JSWrappedValue func (ctx, argv[0 ]);
272283 js::core::JSWrappedValue obj (ctx, this_val);
@@ -276,7 +287,7 @@ namespace ccf::js::extensions::kvhelpers
276287 return JS_ThrowTypeError (ctx, " Argument must be a function" );
277288 }
278289
279- auto handle = GetReadOnlyHandle (jsctx, this_val);
290+ auto * handle = GetReadOnlyHandle (jsctx, this_val);
280291 JS_CHECK_HANDLE (handle);
281292
282293 bool failed = false ;
0 commit comments