LCOV - code coverage report
Current view: top level - core/wasm/exports - SPWasm-data.cc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 65 1084 6.0 %
Date: 2024-05-12 00:16:13 Functions: 7 130 5.4 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2024 Stappler LLC <admin@stappler.dev>
       3             : 
       4             :  Permission is hereby granted, free of charge, to any person obtaining a copy
       5             :  of this software and associated documentation files (the "Software"), to deal
       6             :  in the Software without restriction, including without limitation the rights
       7             :  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       8             :  copies of the Software, and to permit persons to whom the Software is
       9             :  furnished to do so, subject to the following conditions:
      10             : 
      11             :  The above copyright notice and this permission notice shall be included in
      12             :  all copies or substantial portions of the Software.
      13             : 
      14             :  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      17             :  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      18             :  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      19             :  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      20             :  THE SOFTWARE.
      21             :  **/
      22             : 
      23             : #include "SPWasm.h"
      24             : #include "SPData.h"
      25             : #include "SPDataValue.h"
      26             : 
      27             : namespace stappler::wasm {
      28             : 
      29             : enum class ForeachResult {
      30             :         Continue,
      31             :         Stop,
      32             :         Drop,
      33             : };
      34             : 
      35             : struct ValueSource : Ref {
      36             :         Value value;
      37             :         const Value *readOnlySource = nullptr;
      38             : };
      39             : 
      40             : struct ValueContainer {
      41             :         Value *value;
      42             :         Rc<ValueSource> source;
      43             : };
      44             : 
      45          25 : static uint32_t StapplerDataRead(wasm_exec_env_t exec_env, uint8_t *buf, uint32_t bufLen, char *key, uint32_t keyLen) {
      46          25 :         auto mod = ExecEnv::get(exec_env)->getInstance();
      47             : 
      48          25 :         auto val = data::read<Interface>(BytesView(buf, bufLen), StringView(key, keyLen));
      49          25 :         if (val) {
      50          25 :                 auto c = new ValueContainer;
      51          25 :                 c->source = Rc<ValueSource>::alloc();
      52          25 :                 c->source->value = move(val);
      53          25 :                 c->value = &c->source->value;
      54             : 
      55          50 :                 return mod->addHandle(c, [c] {
      56          25 :                         delete c;
      57          25 :                 });
      58             :         }
      59             : 
      60           0 :         return ModuleInstance::InvalidHandle;
      61          25 : }
      62             : 
      63           0 : static uint32_t StapplerDataReadFile(wasm_exec_env_t exec_env, char *buf, uint32_t bufLen, char *key, uint32_t keyLen) {
      64           0 :         auto mod = ExecEnv::get(exec_env)->getInstance();
      65             : 
      66           0 :         auto val = data::readFile<Interface>(StringView(buf, bufLen), StringView(key, keyLen));
      67           0 :         if (val) {
      68           0 :                 auto c = new ValueContainer;
      69           0 :                 c->source = Rc<ValueSource>::alloc();
      70           0 :                 c->source->value = move(val);
      71           0 :                 c->value = &c->source->value;
      72             : 
      73           0 :                 return mod->addHandle(c, [c] {
      74           0 :                         delete c;
      75           0 :                 });
      76             :         }
      77             : 
      78           0 :         return ModuleInstance::InvalidHandle;
      79           0 : }
      80             : 
      81           0 : static uint32_t stappler_wasm_data_constructor_value(wasm_exec_env_t exec_env) {
      82           0 :         auto mod = ExecEnv::get(exec_env)->getInstance();
      83             : 
      84           0 :         auto c = new ValueContainer;
      85           0 :         c->source = Rc<ValueSource>::alloc();
      86           0 :         c->value = &c->source->value;
      87             : 
      88           0 :         return mod->addHandle(c, [c] {
      89           0 :                 delete c;
      90           0 :         });
      91             : }
      92             : 
      93           0 : static uint32_t StapplerDataCopy(wasm_exec_env_t exec_env, uint32_t handle) {
      94           0 :         auto mod = ExecEnv::get(exec_env)->getInstance();
      95           0 :         auto val = mod->getObject<ValueContainer>(handle);
      96           0 :         if (!val) {
      97           0 :                 log::error("wasm::Runtime", "[method]value.copy: invalid handle");
      98           0 :                 return ModuleInstance::InvalidHandle;
      99             :         }
     100             : 
     101           0 :         auto c = new ValueContainer;
     102           0 :         c->source = Rc<ValueSource>::alloc();
     103           0 :         c->source->value = *val->value;
     104           0 :         c->value = &c->source->value;
     105             : 
     106           0 :         return mod->addHandle(c, [c] {
     107           0 :                 delete c;
     108           0 :         });
     109             : }
     110             : 
     111          25 : static void StapplerDataDrop(wasm_exec_env_t exec_env, uint32_t handle) {
     112          25 :         auto mod = ExecEnv::get(exec_env)->getInstance();
     113          25 :         auto val = mod->getObject<ValueContainer>(handle);
     114          25 :         if (!val) {
     115           0 :                 log::error("wasm::Runtime", "[resource-drop]value: invalid handle");
     116           0 :                 return;
     117             :         }
     118             : 
     119          25 :         mod->removeHandle(handle);
     120             : }
     121             : 
     122           0 : static uint32_t StapplerDataWriteToFile(wasm_exec_env_t exec_env, uint32_t handle, char *filename, uint32_t len, uint32_t fmt) {
     123           0 :         auto mod = ExecEnv::get(exec_env)->getInstance();
     124           0 :         auto val = mod->getObject<ValueContainer>(handle);
     125           0 :         if (!val) {
     126           0 :                 log::error("wasm::Runtime", "[method]value.write-to-file: invalid handle");
     127           0 :                 return false;
     128             :         }
     129             : 
     130           0 :         return data::save(*val->value, StringView(filename, len), data::EncodeFormat(fmt));
     131             : }
     132             : 
     133           0 : static uint32_t StapplerDataWriteToMemory(wasm_exec_env_t exec_env, uint32_t handle, uint32_t fmt, ListOutput *out) {
     134           0 :         auto env = ExecEnv::get(exec_env);
     135           0 :         auto mod = env->getInstance();
     136           0 :         auto val = mod->getObject<ValueContainer>(handle);
     137           0 :         if (!val) {
     138           0 :                 log::error("wasm::Runtime", "[method]value.write-to-memory: invalid handle");
     139           0 :                 return false;
     140             :         }
     141             : 
     142           0 :         auto d = data::write(*val->value, data::EncodeFormat(fmt));
     143           0 :         out->setData(mod, d.data(), d.size());
     144           0 :         return true;
     145           0 : }
     146             : 
     147         125 : static uint32_t StapplerDataToString(wasm_exec_env_t exec_env, uint32_t handle, uint32_t fmt, ListOutput *out) {
     148         125 :         auto env = ExecEnv::get(exec_env);
     149         125 :         auto mod = env->getInstance();
     150         125 :         auto val = mod->getObject<ValueContainer>(handle);
     151         125 :         if (!val) {
     152           0 :                 log::error("wasm::Runtime", "[method]value.to-string: invalid handle");
     153           0 :                 return false;
     154             :         }
     155             : 
     156         125 :         auto d = data::toString(*val->value, data::EncodeFormat::Format(fmt));
     157         125 :         out->setData(mod, d.data(), d.size());
     158         125 :         return true;
     159         125 : }
     160             : 
     161           0 : static uint32_t stappler_wasm_data_process_foreach_array(wasm_exec_env_t exec_env, ModuleInstance *inst, ValueContainer *val,
     162             :                 Value::ArrayType &arr, uint32_t callback, uint32_t userdata) {
     163           0 :         ValueContainer iterContainer;
     164           0 :         iterContainer.source = val->source;
     165             : 
     166           0 :         auto iterHandle = inst->addHandle(&iterContainer);
     167             : 
     168           0 :         uint32_t idx = 0;
     169             :         uint32_t args[3];
     170           0 :         auto it = arr.begin();
     171           0 :         while (it != arr.end()) {
     172           0 :                 args[0] = userdata;
     173           0 :                 args[1] = idx;
     174           0 :                 args[2] = iterHandle;
     175             : 
     176           0 :                 iterContainer.value = & (*it);
     177             : 
     178           0 :                 if (!wasm_runtime_call_indirect(exec_env, callback, 3, args)) {
     179           0 :                         log::error("wasm::Runtime", __FUNCTION__, ": fail to call_indirect");
     180           0 :                         inst->removeObject(&iterContainer);
     181           0 :                         return 0;
     182             :                 }
     183             : 
     184           0 :                 ForeachResult res = ForeachResult(args[0]);
     185           0 :                 switch (res) {
     186           0 :                 case ForeachResult::Continue:
     187           0 :                         ++ it;
     188           0 :                         break;
     189           0 :                 case ForeachResult::Stop:
     190           0 :                         it = arr.end();
     191           0 :                         break;
     192           0 :                 case ForeachResult::Drop:
     193           0 :                         if (iterContainer.source->readOnlySource) {
     194           0 :                                 log::error("wasm::Runtime", __FUNCTION__, ": fail to drop in read-only object");
     195           0 :                                 it = arr.end();
     196             :                         } else {
     197           0 :                                 it = arr.erase(it);
     198             :                         }
     199           0 :                         break;
     200             :                 }
     201             : 
     202           0 :                 ++ idx;
     203             :         }
     204             : 
     205           0 :         inst->removeObject(&iterContainer);
     206           0 :         return 1;
     207           0 : }
     208             : 
     209          25 : static uint32_t stappler_wasm_data_process_foreach_dict(wasm_exec_env_t exec_env, ModuleInstance *inst, ValueContainer *val,
     210             :                 Value::DictionaryType &dict, uint32_t callback, uint32_t userdata) {
     211          25 :         ValueContainer iterContainer;
     212          25 :         iterContainer.source = val->source;
     213             : 
     214          25 :         auto iterHandle = inst->addHandle(&iterContainer);
     215             : 
     216          25 :         uint32_t idx = 0;
     217             :         uint32_t args[4];
     218          25 :         auto it = dict.begin();
     219         150 :         while (it != dict.end()) {
     220         125 :                 args[0] = userdata;
     221             : 
     222         125 :                 char *buf = nullptr;
     223         125 :                 auto bufOffset = inst->allocate(it->first.size(), (void **)&buf);
     224             : 
     225         125 :                 memcpy(buf, it->first.data(), it->first.size());
     226             : 
     227         125 :                 args[1] = bufOffset;
     228         125 :                 args[2] = it->first.size();
     229         125 :                 args[3] = iterHandle;
     230             : 
     231         125 :                 iterContainer.value = &it->second;
     232             : 
     233         125 :                 if (!wasm_runtime_call_indirect(exec_env, callback, 4, args)) {
     234           0 :                         log::error("wasm::Runtime", __FUNCTION__, ": fail to call_indirect");
     235           0 :                         inst->free(bufOffset);
     236           0 :                         inst->removeObject(&iterContainer);
     237           0 :                         return 0;
     238             :                 }
     239             : 
     240         125 :                 inst->free(bufOffset);
     241             : 
     242         125 :                 ForeachResult res = ForeachResult(args[0]);
     243         125 :                 switch (res) {
     244         125 :                 case ForeachResult::Continue:
     245         125 :                         ++ it;
     246         125 :                         break;
     247           0 :                 case ForeachResult::Stop:
     248           0 :                         it = dict.end();
     249           0 :                         break;
     250           0 :                 case ForeachResult::Drop:
     251           0 :                         if (iterContainer.source->readOnlySource) {
     252           0 :                                 log::error("wasm::Runtime", __FUNCTION__, ": fail to drop in read-only object");
     253           0 :                                 it = dict.end();
     254             :                         } else {
     255           0 :                                 it = dict.erase(it);
     256             :                         }
     257           0 :                         break;
     258             :                 }
     259             : 
     260         125 :                 ++ idx;
     261             :         }
     262             : 
     263          25 :         inst->removeObject(&iterContainer);
     264          25 :         return 1;
     265          25 : }
     266             : 
     267           0 : static uint32_t stappler_wasm_data_method_value_is_null(wasm_exec_env_t exec_env, uint32_t handle) {
     268           0 :         auto env = ExecEnv::get(exec_env);
     269           0 :         auto mod = env->getInstance();
     270           0 :         auto val = mod->getObject<ValueContainer>(handle);
     271           0 :         if (!val) {
     272           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     273           0 :                 return false;
     274             :         }
     275             : 
     276           0 :         return val->value && val->value->isNull();
     277             : }
     278             : 
     279           0 : static uint32_t stappler_wasm_data_method_value_is_basic_type(wasm_exec_env_t exec_env, uint32_t handle) {
     280           0 :         auto env = ExecEnv::get(exec_env);
     281           0 :         auto mod = env->getInstance();
     282           0 :         auto val = mod->getObject<ValueContainer>(handle);
     283           0 :         if (!val) {
     284           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     285           0 :                 return false;
     286             :         }
     287             : 
     288           0 :         return val->value && val->value->isBasicType();
     289             : }
     290             : 
     291           0 : static uint32_t stappler_wasm_data_method_value_is_array(wasm_exec_env_t exec_env, uint32_t handle) {
     292           0 :         auto env = ExecEnv::get(exec_env);
     293           0 :         auto mod = env->getInstance();
     294           0 :         auto val = mod->getObject<ValueContainer>(handle);
     295           0 :         if (!val) {
     296           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     297           0 :                 return false;
     298             :         }
     299             : 
     300           0 :         return val->value && val->value->isArray();
     301             : }
     302             : 
     303           0 : static uint32_t stappler_wasm_data_method_value_is_dictionary(wasm_exec_env_t exec_env, uint32_t handle) {
     304           0 :         auto env = ExecEnv::get(exec_env);
     305           0 :         auto mod = env->getInstance();
     306           0 :         auto val = mod->getObject<ValueContainer>(handle);
     307           0 :         if (!val) {
     308           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     309           0 :                 return false;
     310             :         }
     311             : 
     312           0 :         return val->value && val->value->isDictionary();
     313             : }
     314             : 
     315           0 : static uint32_t stappler_wasm_data_method_value_is_bool(wasm_exec_env_t exec_env, uint32_t handle) {
     316           0 :         auto env = ExecEnv::get(exec_env);
     317           0 :         auto mod = env->getInstance();
     318           0 :         auto val = mod->getObject<ValueContainer>(handle);
     319           0 :         if (!val) {
     320           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     321           0 :                 return false;
     322             :         }
     323             : 
     324           0 :         return val->value && val->value->isBool();
     325             : }
     326             : 
     327           0 : static uint32_t stappler_wasm_data_method_value_is_integer(wasm_exec_env_t exec_env, uint32_t handle) {
     328           0 :         auto env = ExecEnv::get(exec_env);
     329           0 :         auto mod = env->getInstance();
     330           0 :         auto val = mod->getObject<ValueContainer>(handle);
     331           0 :         if (!val) {
     332           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     333           0 :                 return false;
     334             :         }
     335             : 
     336           0 :         return val->value && val->value->isInteger();
     337             : }
     338             : 
     339           0 : static uint32_t stappler_wasm_data_method_value_is_double(wasm_exec_env_t exec_env, uint32_t handle) {
     340           0 :         auto env = ExecEnv::get(exec_env);
     341           0 :         auto mod = env->getInstance();
     342           0 :         auto val = mod->getObject<ValueContainer>(handle);
     343           0 :         if (!val) {
     344           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     345           0 :                 return false;
     346             :         }
     347             : 
     348           0 :         return val->value && val->value->isDouble();
     349             : }
     350             : 
     351           0 : static uint32_t stappler_wasm_data_method_value_is_string(wasm_exec_env_t exec_env, uint32_t handle) {
     352           0 :         auto env = ExecEnv::get(exec_env);
     353           0 :         auto mod = env->getInstance();
     354           0 :         auto val = mod->getObject<ValueContainer>(handle);
     355           0 :         if (!val) {
     356           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     357           0 :                 return false;
     358             :         }
     359             : 
     360           0 :         return val->value && val->value->isString();
     361             : }
     362             : 
     363           0 : static uint32_t stappler_wasm_data_method_value_is_bytes(wasm_exec_env_t exec_env, uint32_t handle) {
     364           0 :         auto env = ExecEnv::get(exec_env);
     365           0 :         auto mod = env->getInstance();
     366           0 :         auto val = mod->getObject<ValueContainer>(handle);
     367           0 :         if (!val) {
     368           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     369           0 :                 return false;
     370             :         }
     371             : 
     372           0 :         return val->value && val->value->isBytes();
     373             : }
     374             : 
     375           0 : static uint32_t stappler_wasm_data_method_value_get_type(wasm_exec_env_t exec_env, uint32_t handle) {
     376           0 :         auto env = ExecEnv::get(exec_env);
     377           0 :         auto mod = env->getInstance();
     378           0 :         auto val = mod->getObject<ValueContainer>(handle);
     379           0 :         if (!val) {
     380           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     381           0 :                 return false;
     382             :         }
     383             : 
     384           0 :         if (val->value) {
     385           0 :                 return uint32_t(val->value->getType());
     386             :         }
     387           0 :         return uint32_t(Value::Type::NONE);
     388             : }
     389             : 
     390           0 : static uint32_t stappler_wasm_data_method_value_is_null_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     391           0 :         auto env = ExecEnv::get(exec_env);
     392           0 :         auto mod = env->getInstance();
     393           0 :         auto val = mod->getObject<ValueContainer>(handle);
     394           0 :         if (!val) {
     395           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     396           0 :                 return false;
     397             :         }
     398             : 
     399           0 :         return val->value && val->value->isNull(idx);
     400             : }
     401             : 
     402           0 : static uint32_t stappler_wasm_data_method_value_is_basic_type_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     403           0 :         auto env = ExecEnv::get(exec_env);
     404           0 :         auto mod = env->getInstance();
     405           0 :         auto val = mod->getObject<ValueContainer>(handle);
     406           0 :         if (!val) {
     407           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     408           0 :                 return false;
     409             :         }
     410             : 
     411           0 :         return val->value && val->value->isBasicType(idx);
     412             : }
     413             : 
     414           0 : static uint32_t stappler_wasm_data_method_value_is_array_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     415           0 :         auto env = ExecEnv::get(exec_env);
     416           0 :         auto mod = env->getInstance();
     417           0 :         auto val = mod->getObject<ValueContainer>(handle);
     418           0 :         if (!val) {
     419           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     420           0 :                 return false;
     421             :         }
     422             : 
     423           0 :         return val->value && val->value->isArray(idx);
     424             : }
     425             : 
     426           0 : static uint32_t stappler_wasm_data_method_value_is_dictionary_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     427           0 :         auto env = ExecEnv::get(exec_env);
     428           0 :         auto mod = env->getInstance();
     429           0 :         auto val = mod->getObject<ValueContainer>(handle);
     430           0 :         if (!val) {
     431           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     432           0 :                 return false;
     433             :         }
     434             : 
     435           0 :         return val->value && val->value->isDictionary(idx);
     436             : }
     437             : 
     438           0 : static uint32_t stappler_wasm_data_method_value_is_bool_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     439           0 :         auto env = ExecEnv::get(exec_env);
     440           0 :         auto mod = env->getInstance();
     441           0 :         auto val = mod->getObject<ValueContainer>(handle);
     442           0 :         if (!val) {
     443           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     444           0 :                 return false;
     445             :         }
     446             : 
     447           0 :         return val->value && val->value->isBool(idx);
     448             : }
     449             : 
     450           0 : static uint32_t stappler_wasm_data_method_value_is_integer_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     451           0 :         auto env = ExecEnv::get(exec_env);
     452           0 :         auto mod = env->getInstance();
     453           0 :         auto val = mod->getObject<ValueContainer>(handle);
     454           0 :         if (!val) {
     455           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     456           0 :                 return false;
     457             :         }
     458             : 
     459           0 :         return val->value && val->value->isInteger(idx);
     460             : }
     461             : 
     462           0 : static uint32_t stappler_wasm_data_method_value_is_double_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     463           0 :         auto env = ExecEnv::get(exec_env);
     464           0 :         auto mod = env->getInstance();
     465           0 :         auto val = mod->getObject<ValueContainer>(handle);
     466           0 :         if (!val) {
     467           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     468           0 :                 return false;
     469             :         }
     470             : 
     471           0 :         return val->value && val->value->isDouble(idx);
     472             : }
     473             : 
     474           0 : static uint32_t stappler_wasm_data_method_value_is_string_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     475           0 :         auto env = ExecEnv::get(exec_env);
     476           0 :         auto mod = env->getInstance();
     477           0 :         auto val = mod->getObject<ValueContainer>(handle);
     478           0 :         if (!val) {
     479           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     480           0 :                 return false;
     481             :         }
     482             : 
     483           0 :         return val->value && val->value->isString(idx);
     484             : }
     485             : 
     486           0 : static uint32_t stappler_wasm_data_method_value_is_bytes_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     487           0 :         auto env = ExecEnv::get(exec_env);
     488           0 :         auto mod = env->getInstance();
     489           0 :         auto val = mod->getObject<ValueContainer>(handle);
     490           0 :         if (!val) {
     491           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     492           0 :                 return false;
     493             :         }
     494             : 
     495           0 :         return val->value && val->value->isBytes(idx);
     496             : }
     497             : 
     498           0 : static uint32_t stappler_wasm_data_method_value_get_type_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     499           0 :         auto env = ExecEnv::get(exec_env);
     500           0 :         auto mod = env->getInstance();
     501           0 :         auto val = mod->getObject<ValueContainer>(handle);
     502           0 :         if (!val) {
     503           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     504           0 :                 return false;
     505             :         }
     506             : 
     507           0 :         if (val->value) {
     508           0 :                 return uint32_t(val->value->getType(idx));
     509             :         }
     510           0 :         return uint32_t(Value::Type::NONE);
     511             : }
     512             : 
     513           0 : static uint32_t stappler_wasm_data_method_value_has_value_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     514           0 :         auto env = ExecEnv::get(exec_env);
     515           0 :         auto mod = env->getInstance();
     516           0 :         auto val = mod->getObject<ValueContainer>(handle);
     517           0 :         if (!val) {
     518           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     519           0 :                 return false;
     520             :         }
     521             : 
     522           0 :         if (val->value) {
     523           0 :                 return uint32_t(val->value->hasValue(idx));
     524             :         }
     525           0 :         return false;
     526             : }
     527             : 
     528           0 : static uint32_t stappler_wasm_data_method_value_is_null_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     529           0 :         auto env = ExecEnv::get(exec_env);
     530           0 :         auto mod = env->getInstance();
     531           0 :         auto val = mod->getObject<ValueContainer>(handle);
     532           0 :         if (!val) {
     533           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     534           0 :                 return false;
     535             :         }
     536             : 
     537           0 :         return val->value && val->value->isNull(StringView(key, len));
     538             : }
     539             : 
     540           0 : static uint32_t stappler_wasm_data_method_value_is_basic_type_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     541           0 :         auto env = ExecEnv::get(exec_env);
     542           0 :         auto mod = env->getInstance();
     543           0 :         auto val = mod->getObject<ValueContainer>(handle);
     544           0 :         if (!val) {
     545           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     546           0 :                 return false;
     547             :         }
     548             : 
     549           0 :         return val->value && val->value->isBasicType(StringView(key, len));
     550             : }
     551             : 
     552           0 : static uint32_t stappler_wasm_data_method_value_is_array_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     553           0 :         auto env = ExecEnv::get(exec_env);
     554           0 :         auto mod = env->getInstance();
     555           0 :         auto val = mod->getObject<ValueContainer>(handle);
     556           0 :         if (!val) {
     557           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     558           0 :                 return false;
     559             :         }
     560             : 
     561           0 :         return val->value && val->value->isArray(StringView(key, len));
     562             : }
     563             : 
     564           0 : static uint32_t stappler_wasm_data_method_value_is_dictionary_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     565           0 :         auto env = ExecEnv::get(exec_env);
     566           0 :         auto mod = env->getInstance();
     567           0 :         auto val = mod->getObject<ValueContainer>(handle);
     568           0 :         if (!val) {
     569           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     570           0 :                 return false;
     571             :         }
     572             : 
     573           0 :         return val->value && val->value->isDictionary(StringView(key, len));
     574             : }
     575             : 
     576           0 : static uint32_t stappler_wasm_data_method_value_is_bool_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     577           0 :         auto env = ExecEnv::get(exec_env);
     578           0 :         auto mod = env->getInstance();
     579           0 :         auto val = mod->getObject<ValueContainer>(handle);
     580           0 :         if (!val) {
     581           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     582           0 :                 return false;
     583             :         }
     584             : 
     585           0 :         return val->value && val->value->isBool(StringView(key, len));
     586             : }
     587             : 
     588           0 : static uint32_t stappler_wasm_data_method_value_is_integer_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     589           0 :         auto env = ExecEnv::get(exec_env);
     590           0 :         auto mod = env->getInstance();
     591           0 :         auto val = mod->getObject<ValueContainer>(handle);
     592           0 :         if (!val) {
     593           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     594           0 :                 return false;
     595             :         }
     596             : 
     597           0 :         return val->value && val->value->isInteger(StringView(key, len));
     598             : }
     599             : 
     600           0 : static uint32_t stappler_wasm_data_method_value_is_double_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     601           0 :         auto env = ExecEnv::get(exec_env);
     602           0 :         auto mod = env->getInstance();
     603           0 :         auto val = mod->getObject<ValueContainer>(handle);
     604           0 :         if (!val) {
     605           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     606           0 :                 return false;
     607             :         }
     608             : 
     609           0 :         return val->value && val->value->isDouble(StringView(key, len));
     610             : }
     611             : 
     612           0 : static uint32_t stappler_wasm_data_method_value_is_string_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     613           0 :         auto env = ExecEnv::get(exec_env);
     614           0 :         auto mod = env->getInstance();
     615           0 :         auto val = mod->getObject<ValueContainer>(handle);
     616           0 :         if (!val) {
     617           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     618           0 :                 return false;
     619             :         }
     620             : 
     621           0 :         return val->value && val->value->isString(StringView(key, len));
     622             : }
     623             : 
     624           0 : static uint32_t stappler_wasm_data_method_value_is_bytes_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     625           0 :         auto env = ExecEnv::get(exec_env);
     626           0 :         auto mod = env->getInstance();
     627           0 :         auto val = mod->getObject<ValueContainer>(handle);
     628           0 :         if (!val) {
     629           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     630           0 :                 return false;
     631             :         }
     632             : 
     633           0 :         return val->value && val->value->isBytes(StringView(key, len));
     634             : }
     635             : 
     636           0 : static uint32_t stappler_wasm_data_method_value_get_type_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     637           0 :         auto env = ExecEnv::get(exec_env);
     638           0 :         auto mod = env->getInstance();
     639           0 :         auto val = mod->getObject<ValueContainer>(handle);
     640           0 :         if (!val) {
     641           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     642           0 :                 return false;
     643             :         }
     644             : 
     645           0 :         if (val->value) {
     646           0 :                 return uint32_t(val->value->getType(StringView(key, len)));
     647             :         }
     648           0 :         return uint32_t(Value::Type::NONE);
     649             : }
     650             : 
     651           0 : static uint32_t stappler_wasm_data_method_value_has_value_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     652           0 :         auto env = ExecEnv::get(exec_env);
     653           0 :         auto mod = env->getInstance();
     654           0 :         auto val = mod->getObject<ValueContainer>(handle);
     655           0 :         if (!val) {
     656           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     657           0 :                 return false;
     658             :         }
     659             : 
     660           0 :         if (val->value) {
     661           0 :                 return uint32_t(val->value->hasValue(StringView(key, len)));
     662             :         }
     663           0 :         return false;
     664             : }
     665             : 
     666           0 : static uint32_t stappler_wasm_data_method_value_is_read_only(wasm_exec_env_t exec_env, uint32_t handle) {
     667           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     668           0 :         if (!val) {
     669           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     670           0 :                 return true;
     671             :         }
     672             : 
     673           0 :         if (val->value) {
     674           0 :                 return val->source->readOnlySource ? true : false;
     675             :         }
     676           0 :         return true;
     677             : }
     678             : 
     679           0 : static uint32_t stappler_wasm_data_method_value_size(wasm_exec_env_t exec_env, uint32_t handle) {
     680           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     681           0 :         if (!val) {
     682           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     683           0 :                 return 0;
     684             :         }
     685             : 
     686           0 :         if (val->value) {
     687           0 :                 return uint32_t(val->value->size());
     688             :         }
     689           0 :         return 0;
     690             : }
     691             : 
     692           0 : static uint32_t stappler_wasm_data_method_value_empty(wasm_exec_env_t exec_env, uint32_t handle) {
     693           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     694           0 :         if (!val) {
     695           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     696           0 :                 return 0;
     697             :         }
     698             : 
     699           0 :         if (val->value) {
     700           0 :                 return uint32_t(val->value->empty());
     701             :         }
     702           0 :         return 0;
     703             : }
     704             : 
     705           0 : static void stappler_wasm_data_method_value_clear(wasm_exec_env_t exec_env, uint32_t handle) {
     706           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     707           0 :         if (!val) {
     708           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     709           0 :                 return;
     710             :         }
     711             : 
     712           0 :         if (val->value && !val->source->readOnlySource) {
     713           0 :                 val->value->clear();
     714             :         }
     715             : }
     716             : 
     717           0 : static int64_t stappler_wasm_data_method_value_get_integer(wasm_exec_env_t exec_env, uint32_t handle, int64_t def) {
     718           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     719           0 :         if (!val) {
     720           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     721           0 :                 return def;
     722             :         }
     723             : 
     724           0 :         return val->value->getInteger(def);
     725             : }
     726             : 
     727           0 : static double stappler_wasm_data_method_value_get_double(wasm_exec_env_t exec_env, uint32_t handle, double def) {
     728           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     729           0 :         if (!val) {
     730           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     731           0 :                 return def;
     732             :         }
     733             : 
     734           0 :         return val->value->getDouble(def);
     735             : }
     736             : 
     737           0 : static uint32_t stappler_wasm_data_method_value_get_bool(wasm_exec_env_t exec_env, uint32_t handle) {
     738           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     739           0 :         if (!val) {
     740           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     741           0 :                 return false;
     742             :         }
     743             : 
     744           0 :         return val->value->getBool();
     745             : }
     746             : 
     747           0 : static void stappler_wasm_data_method_value_get_string(wasm_exec_env_t exec_env, uint32_t handle, ListOutput *target) {
     748           0 :         auto env = ExecEnv::get(exec_env);
     749           0 :         auto val = env->getInstance()->getObject<ValueContainer>(handle);
     750           0 :         if (!val) {
     751           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     752           0 :                 return;
     753             :         }
     754             : 
     755           0 :         auto str = StringView(val->value->getString());
     756           0 :         target->setData(env->getInstance(), str.data(), str.size());
     757             : }
     758             : 
     759           0 : static void stappler_wasm_data_method_value_get_bytes(wasm_exec_env_t exec_env, uint32_t handle, ListOutput *target) {
     760           0 :         auto env = ExecEnv::get(exec_env);
     761           0 :         auto val = env->getInstance()->getObject<ValueContainer>(handle);
     762           0 :         if (!val) {
     763           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     764           0 :                 return;
     765             :         }
     766             : 
     767           0 :         auto str = BytesView(val->value->getBytes());
     768           0 :         target->setData(env->getInstance(), str.data(), str.size());
     769             : }
     770             : 
     771           0 : static uint32_t stappler_wasm_data_method_value_foreach_array(wasm_exec_env_t exec_env, uint32_t handle, uint32_t callback, uint32_t userdata) {
     772           0 :         auto env = ExecEnv::get(exec_env);
     773           0 :         auto inst = env->getInstance();
     774           0 :         auto val = inst->getObject<ValueContainer>(handle);
     775           0 :         if (!val) {
     776           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     777           0 :                 return 0;
     778             :         }
     779             : 
     780           0 :         if (!val->value->isArray()) {
     781           0 :                 return 0;
     782             :         }
     783             : 
     784           0 :         return stappler_wasm_data_process_foreach_array(exec_env, inst, val, val->value->getArray(), callback, userdata);
     785             : }
     786             : 
     787          25 : static uint32_t stappler_wasm_data_method_value_foreach_dict(wasm_exec_env_t exec_env, uint32_t handle, uint32_t callback, uint32_t userdata) {
     788          25 :         auto env = ExecEnv::get(exec_env);
     789          25 :         auto inst = env->getInstance();
     790          25 :         auto val = inst->getObject<ValueContainer>(handle);
     791          25 :         if (!val) {
     792           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     793           0 :                 return 0;
     794             :         }
     795             : 
     796          25 :         if (!val->value->isDictionary()) {
     797           0 :                 return 0;
     798             :         }
     799             : 
     800          25 :         return stappler_wasm_data_process_foreach_dict(exec_env, inst, val, val->value->getDict(), callback, userdata);
     801             : }
     802             : 
     803           0 : static uint32_t stappler_wasm_data_method_value_get_value_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     804           0 :         auto mod = ExecEnv::get(exec_env)->getInstance();
     805           0 :         auto val = mod->getObject<ValueContainer>(handle);
     806           0 :         if (!val) {
     807           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     808           0 :                 return ModuleInstance::InvalidHandle;
     809             :         }
     810             : 
     811           0 :         if (!val->value->hasValue(idx)) {
     812           0 :                 return ModuleInstance::InvalidHandle;
     813             :         }
     814             : 
     815           0 :         auto &newVal = val->value->getValue(idx);
     816             : 
     817           0 :         auto c = new ValueContainer;
     818           0 :         c->source = val->source;
     819           0 :         c->value = &newVal;
     820             : 
     821           0 :         return mod->addHandle(c, [c] {
     822           0 :                 delete c;
     823           0 :         });
     824             : }
     825             : 
     826           0 : static int64_t stappler_wasm_data_method_value_get_integer_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx, int64_t def) {
     827           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     828           0 :         if (!val) {
     829           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     830           0 :                 return def;
     831             :         }
     832             : 
     833           0 :         return val->value->getInteger(idx, def);
     834             : }
     835             : 
     836           0 : static double stappler_wasm_data_method_value_get_double_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx, double def) {
     837           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     838           0 :         if (!val) {
     839           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     840           0 :                 return def;
     841             :         }
     842             : 
     843           0 :         return val->value->getDouble(idx, def);
     844             : }
     845             : 
     846           0 : static uint32_t stappler_wasm_data_method_value_get_bool_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
     847           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     848           0 :         if (!val) {
     849           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     850           0 :                 return false;
     851             :         }
     852             : 
     853           0 :         return val->value->getBool(idx);
     854             : }
     855             : 
     856           0 : static void stappler_wasm_data_method_value_get_string_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx, ListOutput *target) {
     857           0 :         auto env = ExecEnv::get(exec_env);
     858           0 :         auto val = env->getInstance()->getObject<ValueContainer>(handle);
     859           0 :         if (!val) {
     860           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     861           0 :                 return;
     862             :         }
     863             : 
     864           0 :         auto str = StringView(val->value->getString(idx));
     865           0 :         target->setData(env->getInstance(), str.data(), str.size());
     866             : }
     867             : 
     868           0 : static void stappler_wasm_data_method_value_get_bytes_by_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx, ListOutput *target) {
     869           0 :         auto env = ExecEnv::get(exec_env);
     870           0 :         auto val = env->getInstance()->getObject<ValueContainer>(handle);
     871           0 :         if (!val) {
     872           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     873           0 :                 return;
     874             :         }
     875             : 
     876           0 :         auto str = BytesView(val->value->getBytes(idx));
     877           0 :         target->setData(env->getInstance(), str.data(), str.size());
     878             : }
     879             : 
     880           0 : static uint32_t stappler_wasm_data_method_value_foreach_array_by_idx(wasm_exec_env_t exec_env,
     881             :                 uint32_t handle, uint32_t idx, uint32_t callback, uint32_t userdata) {
     882           0 :         auto env = ExecEnv::get(exec_env);
     883           0 :         auto inst = env->getInstance();
     884           0 :         auto val = inst->getObject<ValueContainer>(handle);
     885           0 :         if (!val) {
     886           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     887           0 :                 return 0;
     888             :         }
     889             : 
     890           0 :         if (!val->value->isArray(idx)) {
     891           0 :                 return 0;
     892             :         }
     893             : 
     894           0 :         return stappler_wasm_data_process_foreach_array(exec_env, inst, val, val->value->getArray(idx), callback, userdata);
     895             : }
     896             : 
     897           0 : static uint32_t stappler_wasm_data_method_value_foreach_dict_by_idx(wasm_exec_env_t exec_env,
     898             :                 uint32_t handle, uint32_t idx, uint32_t callback, uint32_t userdata) {
     899           0 :         auto env = ExecEnv::get(exec_env);
     900           0 :         auto inst = env->getInstance();
     901           0 :         auto val = inst->getObject<ValueContainer>(handle);
     902           0 :         if (!val) {
     903           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     904           0 :                 return 0;
     905             :         }
     906             : 
     907           0 :         if (!val->value->isDictionary(idx)) {
     908           0 :                 return 0;
     909             :         }
     910             : 
     911           0 :         return stappler_wasm_data_process_foreach_dict(exec_env, inst, val, val->value->getDict(idx), callback, userdata);
     912             : }
     913             : 
     914           0 : static uint32_t stappler_wasm_data_method_value_get_value_by_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t len) {
     915           0 :         auto mod = ExecEnv::get(exec_env)->getInstance();
     916           0 :         auto val = mod->getObject<ValueContainer>(handle);
     917           0 :         if (!val) {
     918           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     919           0 :                 return ModuleInstance::InvalidHandle;
     920             :         }
     921             : 
     922           0 :         if (!val->value->hasValue(StringView(key, len))) {
     923           0 :                 return ModuleInstance::InvalidHandle;
     924             :         }
     925             : 
     926           0 :         auto &newVal = val->value->getValue(StringView(key, len));
     927             : 
     928           0 :         auto c = new ValueContainer;
     929           0 :         c->source = val->source;
     930           0 :         c->value = &newVal;
     931             : 
     932           0 :         return mod->addHandle(c, [c] {
     933           0 :                 delete c;
     934           0 :         });
     935             : }
     936             : 
     937           0 : static int64_t stappler_wasm_data_method_value_get_integer_by_key(wasm_exec_env_t exec_env,
     938             :                 uint32_t handle, char *key, uint32_t len, int64_t def) {
     939           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     940           0 :         if (!val) {
     941           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     942           0 :                 return def;
     943             :         }
     944             : 
     945           0 :         return val->value->getInteger(StringView(key, len), def);
     946             : }
     947             : 
     948           0 : static double stappler_wasm_data_method_value_get_double_by_key(wasm_exec_env_t exec_env,
     949             :                 uint32_t handle, char *key, uint32_t len, double def) {
     950           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     951           0 :         if (!val) {
     952           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     953           0 :                 return def;
     954             :         }
     955             : 
     956           0 :         return val->value->getDouble(StringView(key, len), def);
     957             : }
     958             : 
     959           0 : static uint32_t stappler_wasm_data_method_value_get_bool_by_key(wasm_exec_env_t exec_env,
     960             :                 uint32_t handle, char *key, uint32_t len) {
     961           0 :         auto val = ExecEnv::get(exec_env)->getInstance()->getObject<ValueContainer>(handle);
     962           0 :         if (!val) {
     963           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     964           0 :                 return false;
     965             :         }
     966             : 
     967           0 :         return val->value->getBool(StringView(key, len));
     968             : }
     969             : 
     970           0 : static void stappler_wasm_data_method_value_get_string_by_key(wasm_exec_env_t exec_env,
     971             :                 uint32_t handle, char *key, uint32_t len, ListOutput *target) {
     972           0 :         auto env = ExecEnv::get(exec_env);
     973           0 :         auto val = env->getInstance()->getObject<ValueContainer>(handle);
     974           0 :         if (!val) {
     975           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     976           0 :                 return;
     977             :         }
     978             : 
     979           0 :         auto str = StringView(val->value->getString(StringView(key, len)));
     980           0 :         target->setData(env->getInstance(), str.data(), str.size());
     981             : }
     982             : 
     983           0 : static void stappler_wasm_data_method_value_get_bytes_by_key(wasm_exec_env_t exec_env,
     984             :                 uint32_t handle, char *key, uint32_t len, ListOutput *target) {
     985           0 :         auto env = ExecEnv::get(exec_env);
     986           0 :         auto val = env->getInstance()->getObject<ValueContainer>(handle);
     987           0 :         if (!val) {
     988           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
     989           0 :                 return;
     990             :         }
     991             : 
     992           0 :         auto str = BytesView(val->value->getBytes(StringView(key, len)));
     993           0 :         target->setData(env->getInstance(), str.data(), str.size());
     994             : }
     995             : 
     996           0 : static uint32_t stappler_wasm_data_method_value_foreach_array_by_key(wasm_exec_env_t exec_env,
     997             :                 uint32_t handle, char *key, uint32_t len, uint32_t callback, uint32_t userdata) {
     998           0 :         auto env = ExecEnv::get(exec_env);
     999           0 :         auto inst = env->getInstance();
    1000           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1001           0 :         if (!val) {
    1002           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1003           0 :                 return 0;
    1004             :         }
    1005             : 
    1006           0 :         if (!val->value->isArray(StringView(key, len))) {
    1007           0 :                 return 0;
    1008             :         }
    1009             : 
    1010           0 :         return stappler_wasm_data_process_foreach_array(exec_env, inst, val, val->value->getArray(StringView(key, len)), callback, userdata);
    1011             : }
    1012             : 
    1013           0 : static uint32_t stappler_wasm_data_method_value_foreach_dict_by_key(wasm_exec_env_t exec_env,
    1014             :                 uint32_t handle, char *key, uint32_t len, uint32_t callback, uint32_t userdata) {
    1015           0 :         auto env = ExecEnv::get(exec_env);
    1016           0 :         auto inst = env->getInstance();
    1017           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1018           0 :         if (!val) {
    1019           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1020           0 :                 return 0;
    1021             :         }
    1022             : 
    1023           0 :         if (!val->value->isDictionary(StringView(key, len))) {
    1024           0 :                 return 0;
    1025             :         }
    1026             : 
    1027           0 :         return stappler_wasm_data_process_foreach_dict(exec_env, inst, val, val->value->getDict(StringView(key, len)), callback, userdata);
    1028             : }
    1029             : 
    1030           0 : static void stappler_wasm_data_method_value_set_null(wasm_exec_env_t exec_env, uint32_t handle) {
    1031           0 :         auto env = ExecEnv::get(exec_env);
    1032           0 :         auto inst = env->getInstance();
    1033           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1034           0 :         if (!val) {
    1035           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1036           0 :                 return;
    1037             :         }
    1038             : 
    1039           0 :         val->value->setNull();
    1040             : }
    1041           0 : static void stappler_wasm_data_method_value_set_bool(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value) {
    1042           0 :         auto env = ExecEnv::get(exec_env);
    1043           0 :         auto inst = env->getInstance();
    1044           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1045           0 :         if (!val) {
    1046           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1047           0 :                 return;
    1048             :         }
    1049             : 
    1050           0 :         val->value->setBool(value);
    1051             : }
    1052           0 : static void stappler_wasm_data_method_value_set_integer(wasm_exec_env_t exec_env, uint32_t handle, int64_t value) {
    1053           0 :         auto env = ExecEnv::get(exec_env);
    1054           0 :         auto inst = env->getInstance();
    1055           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1056           0 :         if (!val) {
    1057           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1058           0 :                 return;
    1059             :         }
    1060             : 
    1061           0 :         val->value->setInteger(value);
    1062             : }
    1063           0 : static void stappler_wasm_data_method_value_set_double(wasm_exec_env_t exec_env, uint32_t handle, double value) {
    1064           0 :         auto env = ExecEnv::get(exec_env);
    1065           0 :         auto inst = env->getInstance();
    1066           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1067           0 :         if (!val) {
    1068           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1069           0 :                 return;
    1070             :         }
    1071             : 
    1072           0 :         val->value->setDouble(value);
    1073             : }
    1074           0 : static void stappler_wasm_data_method_value_set_string(wasm_exec_env_t exec_env, uint32_t handle, char *value, uint32_t len) {
    1075           0 :         auto env = ExecEnv::get(exec_env);
    1076           0 :         auto inst = env->getInstance();
    1077           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1078           0 :         if (!val) {
    1079           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1080           0 :                 return;
    1081             :         }
    1082             : 
    1083           0 :         val->value->setString(StringView(value, len));
    1084             : }
    1085           0 : static void stappler_wasm_data_method_value_set_bytes(wasm_exec_env_t exec_env, uint32_t handle, uint8_t *value, uint32_t len) {
    1086           0 :         auto env = ExecEnv::get(exec_env);
    1087           0 :         auto inst = env->getInstance();
    1088           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1089           0 :         if (!val) {
    1090           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1091           0 :                 return;
    1092             :         }
    1093             : 
    1094           0 :         val->value->setBytes(BytesView(value, len));
    1095             : }
    1096           0 : static void stappler_wasm_data_method_value_set_dict(wasm_exec_env_t exec_env, uint32_t handle) {
    1097           0 :         auto env = ExecEnv::get(exec_env);
    1098           0 :         auto inst = env->getInstance();
    1099           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1100           0 :         if (!val) {
    1101           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1102           0 :                 return;
    1103             :         }
    1104             : 
    1105           0 :         val->value->setDict(Value::DictionaryType());
    1106             : }
    1107           0 : static void stappler_wasm_data_method_value_set_array(wasm_exec_env_t exec_env, uint32_t handle) {
    1108           0 :         auto env = ExecEnv::get(exec_env);
    1109           0 :         auto inst = env->getInstance();
    1110           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1111           0 :         if (!val) {
    1112           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1113           0 :                 return;
    1114             :         }
    1115             : 
    1116           0 :         val->value->setArray(Value::ArrayType());
    1117             : }
    1118           0 : static void stappler_wasm_data_method_value_set_value_copy(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value) {
    1119           0 :         auto env = ExecEnv::get(exec_env);
    1120           0 :         auto inst = env->getInstance();
    1121           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1122           0 :         if (!val) {
    1123           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1124           0 :                 return;
    1125             :         }
    1126           0 :         auto source = inst->getObject<ValueContainer>(value);
    1127           0 :         if (!source) {
    1128           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1129           0 :                 return;
    1130             :         }
    1131             : 
    1132           0 :         val->value->setValue(*source->value);
    1133             : }
    1134           0 : static void stappler_wasm_data_method_value_set_null_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t index) {
    1135           0 :         auto env = ExecEnv::get(exec_env);
    1136           0 :         auto inst = env->getInstance();
    1137           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1138           0 :         if (!val) {
    1139           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1140           0 :                 return;
    1141             :         }
    1142             : 
    1143           0 :         val->value->setNull(index);
    1144             : }
    1145           0 : static void stappler_wasm_data_method_value_set_bool_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value, uint32_t index) {
    1146           0 :         auto env = ExecEnv::get(exec_env);
    1147           0 :         auto inst = env->getInstance();
    1148           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1149           0 :         if (!val) {
    1150           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1151           0 :                 return;
    1152             :         }
    1153             : 
    1154           0 :         val->value->setBool(value, index);
    1155             : }
    1156           0 : static void stappler_wasm_data_method_value_set_integer_for_idx(wasm_exec_env_t exec_env, uint32_t handle, int64_t value, uint32_t index) {
    1157           0 :         auto env = ExecEnv::get(exec_env);
    1158           0 :         auto inst = env->getInstance();
    1159           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1160           0 :         if (!val) {
    1161           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1162           0 :                 return;
    1163             :         }
    1164             : 
    1165           0 :         val->value->setInteger(value, index);
    1166             : }
    1167           0 : static void stappler_wasm_data_method_value_set_double_for_idx(wasm_exec_env_t exec_env, uint32_t handle, double value, uint32_t index) {
    1168           0 :         auto env = ExecEnv::get(exec_env);
    1169           0 :         auto inst = env->getInstance();
    1170           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1171           0 :         if (!val) {
    1172           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1173           0 :                 return;
    1174             :         }
    1175             : 
    1176           0 :         val->value->setDouble(value, index);
    1177             : }
    1178           0 : static void stappler_wasm_data_method_value_set_string_for_idx(wasm_exec_env_t exec_env, uint32_t handle, char *value, uint32_t len, uint32_t index) {
    1179           0 :         auto env = ExecEnv::get(exec_env);
    1180           0 :         auto inst = env->getInstance();
    1181           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1182           0 :         if (!val) {
    1183           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1184           0 :                 return;
    1185             :         }
    1186             : 
    1187           0 :         val->value->setString(StringView(value, len), index);
    1188             : }
    1189           0 : static void stappler_wasm_data_method_value_set_bytes_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint8_t *value, uint32_t len, uint32_t index) {
    1190           0 :         auto env = ExecEnv::get(exec_env);
    1191           0 :         auto inst = env->getInstance();
    1192           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1193           0 :         if (!val) {
    1194           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1195           0 :                 return;
    1196             :         }
    1197             : 
    1198           0 :         val->value->setBytes(BytesView(value, len), index);
    1199             : }
    1200           0 : static uint32_t stappler_wasm_data_method_value_set_dict_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t index) {
    1201           0 :         auto env = ExecEnv::get(exec_env);
    1202           0 :         auto inst = env->getInstance();
    1203           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1204           0 :         if (!val) {
    1205           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1206           0 :                 return ModuleInstance::InvalidHandle;
    1207             :         }
    1208             : 
    1209           0 :         auto &v = val->value->setValue(Value(Value::DictionaryType()), index);
    1210           0 :         auto c = new ValueContainer;
    1211           0 :         c->source = val->source;
    1212           0 :         c->value = &v;
    1213           0 :         return inst->addHandle(c, [c] {
    1214           0 :                 delete c;
    1215           0 :         });
    1216             : }
    1217           0 : static uint32_t stappler_wasm_data_method_value_set_array_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t index) {
    1218           0 :         auto env = ExecEnv::get(exec_env);
    1219           0 :         auto inst = env->getInstance();
    1220           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1221           0 :         if (!val) {
    1222           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1223           0 :                 return ModuleInstance::InvalidHandle;
    1224             :         }
    1225             : 
    1226           0 :         auto &v = val->value->setValue(Value(Value::ArrayType()), index);
    1227           0 :         auto c = new ValueContainer;
    1228           0 :         c->source = val->source;
    1229           0 :         c->value = &v;
    1230           0 :         return inst->addHandle(c, [c] {
    1231           0 :                 delete c;
    1232           0 :         });
    1233             : }
    1234           0 : static uint32_t stappler_wasm_data_method_value_set_value_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t index) {
    1235           0 :         auto env = ExecEnv::get(exec_env);
    1236           0 :         auto inst = env->getInstance();
    1237           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1238           0 :         if (!val) {
    1239           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1240           0 :                 return ModuleInstance::InvalidHandle;
    1241             :         }
    1242             : 
    1243           0 :         auto &v = val->value->setValue(Value(), index);
    1244           0 :         auto c = new ValueContainer;
    1245           0 :         c->source = val->source;
    1246           0 :         c->value = &v;
    1247           0 :         return inst->addHandle(c, [c] {
    1248           0 :                 delete c;
    1249           0 :         });
    1250             : }
    1251           0 : static uint32_t stappler_wasm_data_method_value_set_value_copy_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value, uint32_t index) {
    1252           0 :         auto env = ExecEnv::get(exec_env);
    1253           0 :         auto inst = env->getInstance();
    1254           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1255           0 :         if (!val) {
    1256           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1257           0 :                 return ModuleInstance::InvalidHandle;
    1258             :         }
    1259           0 :         auto source = inst->getObject<ValueContainer>(value);
    1260           0 :         if (!source) {
    1261           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1262           0 :                 return ModuleInstance::InvalidHandle;
    1263             :         }
    1264             : 
    1265           0 :         auto &v = val->value->setValue(*source->value, index);
    1266           0 :         auto c = new ValueContainer;
    1267           0 :         c->source = val->source;
    1268           0 :         c->value = &v;
    1269           0 :         return inst->addHandle(c, [c] {
    1270           0 :                 delete c;
    1271           0 :         });
    1272             : }
    1273           0 : static void stappler_wasm_data_method_value_set_null_for_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t keyLen) {
    1274           0 :         auto env = ExecEnv::get(exec_env);
    1275           0 :         auto inst = env->getInstance();
    1276           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1277           0 :         if (!val) {
    1278           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1279           0 :                 return;
    1280             :         }
    1281             : 
    1282           0 :         val->value->setNull(StringView(key, keyLen));
    1283             : }
    1284           0 : static void stappler_wasm_data_method_value_set_bool_for_key(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value, char *key, uint32_t keyLen) {
    1285           0 :         auto env = ExecEnv::get(exec_env);
    1286           0 :         auto inst = env->getInstance();
    1287           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1288           0 :         if (!val) {
    1289           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1290           0 :                 return;
    1291             :         }
    1292             : 
    1293           0 :         val->value->setBool(value, StringView(key, keyLen));
    1294             : }
    1295           0 : static void stappler_wasm_data_method_value_set_integer_for_key(wasm_exec_env_t exec_env, uint32_t handle, int64_t value, char *key, uint32_t keyLen) {
    1296           0 :         auto env = ExecEnv::get(exec_env);
    1297           0 :         auto inst = env->getInstance();
    1298           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1299           0 :         if (!val) {
    1300           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1301           0 :                 return;
    1302             :         }
    1303             : 
    1304           0 :         val->value->setInteger(value, StringView(key, keyLen));
    1305             : }
    1306           0 : static void stappler_wasm_data_method_value_set_double_for_key(wasm_exec_env_t exec_env, uint32_t handle, double value, char *key, uint32_t keyLen) {
    1307           0 :         auto env = ExecEnv::get(exec_env);
    1308           0 :         auto inst = env->getInstance();
    1309           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1310           0 :         if (!val) {
    1311           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1312           0 :                 return;
    1313             :         }
    1314             : 
    1315           0 :         val->value->setDouble(value, StringView(key, keyLen));
    1316             : }
    1317          25 : static void stappler_wasm_data_method_value_set_string_for_key(wasm_exec_env_t exec_env, uint32_t handle, char *value, uint32_t len, char *key, uint32_t keyLen) {
    1318          25 :         auto env = ExecEnv::get(exec_env);
    1319          25 :         auto inst = env->getInstance();
    1320          25 :         auto val = inst->getObject<ValueContainer>(handle);
    1321          25 :         if (!val) {
    1322           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1323           0 :                 return;
    1324             :         }
    1325             : 
    1326          25 :         val->value->setString(StringView(value, len), StringView(key, keyLen));
    1327             : }
    1328           0 : static void stappler_wasm_data_method_value_set_bytes_for_key(wasm_exec_env_t exec_env, uint32_t handle, uint8_t *value, uint32_t len, char *key, uint32_t keyLen) {
    1329           0 :         auto env = ExecEnv::get(exec_env);
    1330           0 :         auto inst = env->getInstance();
    1331           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1332           0 :         if (!val) {
    1333           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1334           0 :                 return;
    1335             :         }
    1336             : 
    1337           0 :         val->value->setBytes(BytesView(value, len), StringView(key, keyLen));
    1338             : }
    1339           0 : static uint32_t stappler_wasm_data_method_value_set_dict_for_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t keyLen) {
    1340           0 :         auto env = ExecEnv::get(exec_env);
    1341           0 :         auto inst = env->getInstance();
    1342           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1343           0 :         if (!val) {
    1344           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1345           0 :                 return ModuleInstance::InvalidHandle;
    1346             :         }
    1347             : 
    1348           0 :         auto &v = val->value->setValue(Value(Value::DictionaryType()), StringView(key, keyLen));
    1349           0 :         auto c = new ValueContainer;
    1350           0 :         c->source = val->source;
    1351           0 :         c->value = &v;
    1352           0 :         return inst->addHandle(c, [c] {
    1353           0 :                 delete c;
    1354           0 :         });
    1355             : }
    1356           0 : static uint32_t stappler_wasm_data_method_value_set_array_for_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t keyLen) {
    1357           0 :         auto env = ExecEnv::get(exec_env);
    1358           0 :         auto inst = env->getInstance();
    1359           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1360           0 :         if (!val) {
    1361           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1362           0 :                 return ModuleInstance::InvalidHandle;
    1363             :         }
    1364             : 
    1365           0 :         auto &v = val->value->setValue(Value(Value::ArrayType()), StringView(key, keyLen));
    1366           0 :         auto c = new ValueContainer;
    1367           0 :         c->source = val->source;
    1368           0 :         c->value = &v;
    1369           0 :         return inst->addHandle(c, [c] {
    1370           0 :                 delete c;
    1371           0 :         });
    1372             : }
    1373           0 : static uint32_t stappler_wasm_data_method_value_set_value_for_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t keyLen) {
    1374           0 :         auto env = ExecEnv::get(exec_env);
    1375           0 :         auto inst = env->getInstance();
    1376           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1377           0 :         if (!val) {
    1378           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1379           0 :                 return ModuleInstance::InvalidHandle;
    1380             :         }
    1381             : 
    1382           0 :         auto &v = val->value->setValue(Value(), StringView(key, keyLen));
    1383           0 :         auto c = new ValueContainer;
    1384           0 :         c->source = val->source;
    1385           0 :         c->value = &v;
    1386           0 :         return inst->addHandle(c, [c] {
    1387           0 :                 delete c;
    1388           0 :         });
    1389             : }
    1390           0 : static uint32_t stappler_wasm_data_method_value_set_value_copy_for_key(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value, char *key, uint32_t keyLen) {
    1391           0 :         auto env = ExecEnv::get(exec_env);
    1392           0 :         auto inst = env->getInstance();
    1393           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1394           0 :         if (!val) {
    1395           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1396           0 :                 return ModuleInstance::InvalidHandle;
    1397             :         }
    1398             : 
    1399           0 :         auto source = inst->getObject<ValueContainer>(value);
    1400           0 :         if (!source) {
    1401           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1402           0 :                 return ModuleInstance::InvalidHandle;
    1403             :         }
    1404             : 
    1405           0 :         auto &v = val->value->setValue(Value(*source->value), StringView(key, keyLen));
    1406           0 :         auto c = new ValueContainer;
    1407           0 :         c->source = val->source;
    1408           0 :         c->value = &v;
    1409           0 :         return inst->addHandle(c, [c] {
    1410           0 :                 delete c;
    1411           0 :         });
    1412             : }
    1413           0 : static void stappler_wasm_data_method_value_add_null(wasm_exec_env_t exec_env, uint32_t handle) {
    1414           0 :         auto env = ExecEnv::get(exec_env);
    1415           0 :         auto inst = env->getInstance();
    1416           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1417           0 :         if (!val) {
    1418           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1419           0 :                 return;
    1420             :         }
    1421             : 
    1422           0 :         val->value->addValue(Value());
    1423             : }
    1424           0 : static void stappler_wasm_data_method_value_add_bool(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value) {
    1425           0 :         auto env = ExecEnv::get(exec_env);
    1426           0 :         auto inst = env->getInstance();
    1427           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1428           0 :         if (!val) {
    1429           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1430           0 :                 return;
    1431             :         }
    1432             : 
    1433           0 :         val->value->addBool(value);
    1434             : }
    1435           0 : static void stappler_wasm_data_method_value_add_integer(wasm_exec_env_t exec_env, uint32_t handle, int64_t value) {
    1436           0 :         auto env = ExecEnv::get(exec_env);
    1437           0 :         auto inst = env->getInstance();
    1438           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1439           0 :         if (!val) {
    1440           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1441           0 :                 return;
    1442             :         }
    1443             : 
    1444           0 :         val->value->addInteger(value);
    1445             : }
    1446           0 : static void stappler_wasm_data_method_value_add_double(wasm_exec_env_t exec_env, uint32_t handle, double value) {
    1447           0 :         auto env = ExecEnv::get(exec_env);
    1448           0 :         auto inst = env->getInstance();
    1449           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1450           0 :         if (!val) {
    1451           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1452           0 :                 return;
    1453             :         }
    1454             : 
    1455           0 :         val->value->addDouble(value);
    1456             : }
    1457           0 : static void stappler_wasm_data_method_value_add_string(wasm_exec_env_t exec_env, uint32_t handle, char *value, uint32_t len) {
    1458           0 :         auto env = ExecEnv::get(exec_env);
    1459           0 :         auto inst = env->getInstance();
    1460           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1461           0 :         if (!val) {
    1462           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1463           0 :                 return;
    1464             :         }
    1465             : 
    1466           0 :         val->value->addString(StringView(value, len));
    1467             : }
    1468           0 : static void stappler_wasm_data_method_value_add_bytes(wasm_exec_env_t exec_env, uint32_t handle, uint8_t *value, uint32_t len) {
    1469           0 :         auto env = ExecEnv::get(exec_env);
    1470           0 :         auto inst = env->getInstance();
    1471           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1472           0 :         if (!val) {
    1473           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1474           0 :                 return;
    1475             :         }
    1476             : 
    1477           0 :         val->value->addBytes(BytesView(value, len));
    1478             : }
    1479           0 : static uint32_t stappler_wasm_data_method_value_add_dict(wasm_exec_env_t exec_env, uint32_t handle) {
    1480           0 :         auto env = ExecEnv::get(exec_env);
    1481           0 :         auto inst = env->getInstance();
    1482           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1483           0 :         if (!val) {
    1484           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1485           0 :                 return ModuleInstance::InvalidHandle;
    1486             :         }
    1487             : 
    1488           0 :         auto &v = val->value->addArray();
    1489           0 :         auto c = new ValueContainer;
    1490           0 :         c->source = val->source;
    1491           0 :         c->value = &v;
    1492           0 :         return inst->addHandle(c, [c] {
    1493           0 :                 delete c;
    1494           0 :         });
    1495             : }
    1496           0 : static uint32_t stappler_wasm_data_method_value_add_array(wasm_exec_env_t exec_env, uint32_t handle) {
    1497           0 :         auto env = ExecEnv::get(exec_env);
    1498           0 :         auto inst = env->getInstance();
    1499           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1500           0 :         if (!val) {
    1501           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1502           0 :                 return ModuleInstance::InvalidHandle;
    1503             :         }
    1504             : 
    1505           0 :         auto &v = val->value->addDict();
    1506           0 :         auto c = new ValueContainer;
    1507           0 :         c->source = val->source;
    1508           0 :         c->value = &v;
    1509           0 :         return inst->addHandle(c, [c] {
    1510           0 :                 delete c;
    1511           0 :         });
    1512             : }
    1513           0 : static uint32_t stappler_wasm_data_method_value_add_value(wasm_exec_env_t exec_env, uint32_t handle) {
    1514           0 :         auto env = ExecEnv::get(exec_env);
    1515           0 :         auto inst = env->getInstance();
    1516           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1517           0 :         if (!val) {
    1518           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1519           0 :                 return ModuleInstance::InvalidHandle;
    1520             :         }
    1521             : 
    1522           0 :         auto &v = val->value->addValue(Value());
    1523           0 :         auto c = new ValueContainer;
    1524           0 :         c->source = val->source;
    1525           0 :         c->value = &v;
    1526           0 :         return inst->addHandle(c, [c] {
    1527           0 :                 delete c;
    1528           0 :         });
    1529             : }
    1530           0 : static uint32_t stappler_wasm_data_method_value_add_value_copy(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value) {
    1531           0 :         auto env = ExecEnv::get(exec_env);
    1532           0 :         auto inst = env->getInstance();
    1533           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1534           0 :         if (!val) {
    1535           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1536           0 :                 return ModuleInstance::InvalidHandle;
    1537             :         }
    1538             : 
    1539           0 :         auto source = inst->getObject<ValueContainer>(value);
    1540           0 :         if (!source) {
    1541           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1542           0 :                 return ModuleInstance::InvalidHandle;
    1543             :         }
    1544             : 
    1545           0 :         auto &v = val->value->addValue(*source->value);
    1546           0 :         auto c = new ValueContainer;
    1547           0 :         c->source = val->source;
    1548           0 :         c->value = &v;
    1549           0 :         return inst->addHandle(c, [c] {
    1550           0 :                 delete c;
    1551           0 :         });
    1552             : }
    1553           0 : static uint32_t stappler_wasm_data_method_value_erase_for_idx(wasm_exec_env_t exec_env, uint32_t handle, uint32_t idx) {
    1554           0 :         auto env = ExecEnv::get(exec_env);
    1555           0 :         auto inst = env->getInstance();
    1556           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1557           0 :         if (!val) {
    1558           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1559           0 :                 return false;
    1560             :         }
    1561             : 
    1562           0 :         return val->value->erase(idx);
    1563             : }
    1564           0 : static uint32_t stappler_wasm_data_method_value_erase_for_key(wasm_exec_env_t exec_env, uint32_t handle, char *key, uint32_t keyLen) {
    1565           0 :         auto env = ExecEnv::get(exec_env);
    1566           0 :         auto inst = env->getInstance();
    1567           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1568           0 :         if (!val) {
    1569           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1570           0 :                 return false;
    1571             :         }
    1572             : 
    1573           0 :         return val->value->erase(StringView(key, keyLen));
    1574             : }
    1575           0 : static uint32_t stappler_wasm_data_method_value_is_equal(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value) {
    1576           0 :         auto env = ExecEnv::get(exec_env);
    1577           0 :         auto inst = env->getInstance();
    1578           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1579           0 :         if (!val) {
    1580           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1581           0 :                 return false;
    1582             :         }
    1583             : 
    1584           0 :         auto source = inst->getObject<ValueContainer>(value);
    1585           0 :         if (!source) {
    1586           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1587           0 :                 return false;
    1588             :         }
    1589             : 
    1590           0 :         return *val->value == *source->value;
    1591             : }
    1592           0 : static uint32_t stappler_wasm_data_method_value_is_not_equal(wasm_exec_env_t exec_env, uint32_t handle, uint32_t value) {
    1593           0 :         auto env = ExecEnv::get(exec_env);
    1594           0 :         auto inst = env->getInstance();
    1595           0 :         auto val = inst->getObject<ValueContainer>(handle);
    1596           0 :         if (!val) {
    1597           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1598           0 :                 return true;
    1599             :         }
    1600             : 
    1601           0 :         auto source = inst->getObject<ValueContainer>(value);
    1602           0 :         if (!source) {
    1603           0 :                 log::error("wasm::Runtime", __FUNCTION__, ": invalid handle");
    1604           0 :                 return true;
    1605             :         }
    1606             : 
    1607           0 :         return *val->value != *source->value;
    1608             : }
    1609             : 
    1610             : static NativeSymbol stapper_data_symbols[] = {
    1611             :         NativeSymbol{"read", (void *)&StapplerDataRead, "(*~*~)i", NULL},
    1612             :         NativeSymbol{"read-file", (void *)&StapplerDataReadFile, "(*~*~)i", NULL},
    1613             : 
    1614             :         NativeSymbol{"[constructor]value", (void *)&stappler_wasm_data_constructor_value, "()i", NULL},
    1615             : 
    1616             :         NativeSymbol{"[method]value.copy", (void *)&StapplerDataCopy, "(i)i", NULL},
    1617             :         NativeSymbol{"[method]value.write-to-file", (void *)&StapplerDataWriteToFile, "(i*~)i", NULL},
    1618             :         NativeSymbol{"[method]value.write-to-memory", (void *)&StapplerDataWriteToMemory, "(ii*)i", NULL},
    1619             :         NativeSymbol{"[method]value.to-string", (void *)&StapplerDataToString, "(ii*)", NULL},
    1620             : 
    1621             :         NativeSymbol{"[method]is-read-only", (void *)&stappler_wasm_data_method_value_is_read_only, "(i)i",  NULL},
    1622             :         NativeSymbol{"[method]size", (void *)&stappler_wasm_data_method_value_size, "(i)i",  NULL},
    1623             :         NativeSymbol{"[method]empty", (void *)&stappler_wasm_data_method_value_empty, "(i)i",  NULL},
    1624             :         NativeSymbol{"[method]clear", (void *)&stappler_wasm_data_method_value_clear, "(i)", NULL},
    1625             : 
    1626             :         NativeSymbol{"[method]value.is-null", (void *)&stappler_wasm_data_method_value_is_null, "(i)i", NULL},
    1627             :         NativeSymbol{"[method]value.is-basic-type", (void *)&stappler_wasm_data_method_value_is_basic_type, "(i)i", NULL},
    1628             :         NativeSymbol{"[method]value.is-array", (void *)&stappler_wasm_data_method_value_is_array, "(i)i", NULL},
    1629             :         NativeSymbol{"[method]value.is-dictionary", (void *)&stappler_wasm_data_method_value_is_dictionary, "(i)i", NULL},
    1630             :         NativeSymbol{"[method]value.is-bool", (void *)&stappler_wasm_data_method_value_is_bool, "(i)i", NULL},
    1631             :         NativeSymbol{"[method]value.is-integer", (void *)&stappler_wasm_data_method_value_is_integer, "(i)i", NULL},
    1632             :         NativeSymbol{"[method]value.is-double", (void *)&stappler_wasm_data_method_value_is_double, "(i)i", NULL},
    1633             :         NativeSymbol{"[method]value.is-string", (void *)&stappler_wasm_data_method_value_is_string, "(i)i", NULL},
    1634             :         NativeSymbol{"[method]value.is-bytes", (void *)&stappler_wasm_data_method_value_is_bytes, "(i)i", NULL},
    1635             :         NativeSymbol{"[method]value.get-type", (void *)&stappler_wasm_data_method_value_get_type, "(i)i", NULL},
    1636             :         NativeSymbol{"[method]value.is-null-by-idx", (void *)&stappler_wasm_data_method_value_is_null_by_idx, "(ii)i", NULL},
    1637             :         NativeSymbol{"[method]value.is-basic-type-by-idx", (void *)&stappler_wasm_data_method_value_is_basic_type_by_idx, "(ii)i", NULL},
    1638             :         NativeSymbol{"[method]value.is-array-by-idx", (void *)&stappler_wasm_data_method_value_is_array_by_idx, "(ii)i", NULL},
    1639             :         NativeSymbol{"[method]value.is-dictionary-by-idx", (void *)&stappler_wasm_data_method_value_is_dictionary_by_idx, "(ii)i", NULL},
    1640             :         NativeSymbol{"[method]value.is-bool-by-idx", (void *)&stappler_wasm_data_method_value_is_bool_by_idx, "(ii)i", NULL},
    1641             :         NativeSymbol{"[method]value.is-integer-by-idx", (void *)&stappler_wasm_data_method_value_is_integer_by_idx, "(ii)i", NULL},
    1642             :         NativeSymbol{"[method]value.is-double-by-idx", (void *)&stappler_wasm_data_method_value_is_double_by_idx, "(ii)i", NULL},
    1643             :         NativeSymbol{"[method]value.is-string-by-idx", (void *)&stappler_wasm_data_method_value_is_string_by_idx, "(ii)i", NULL},
    1644             :         NativeSymbol{"[method]value.is-bytes-by-idx", (void *)&stappler_wasm_data_method_value_is_bytes_by_idx, "(ii)i", NULL},
    1645             :         NativeSymbol{"[method]value.get-type-by-idx", (void *)&stappler_wasm_data_method_value_get_type_by_idx, "(ii)i", NULL},
    1646             :         NativeSymbol{"[method]value.has-value-by-key", (void *)&stappler_wasm_data_method_value_has_value_by_idx, "(ii)i", NULL},
    1647             :         NativeSymbol{"[method]value.is-null-by-key", (void *)&stappler_wasm_data_method_value_is_null_by_key, "(i*~)i", NULL},
    1648             :         NativeSymbol{"[method]value.is-basic-type-by-key", (void *)&stappler_wasm_data_method_value_is_basic_type_by_key, "(i*~)i", NULL},
    1649             :         NativeSymbol{"[method]value.is-array-by-key", (void *)&stappler_wasm_data_method_value_is_array_by_key, "(i*~)i", NULL},
    1650             :         NativeSymbol{"[method]value.is-dictionary-by-key", (void *)&stappler_wasm_data_method_value_is_dictionary_by_key, "(i*~)i", NULL},
    1651             :         NativeSymbol{"[method]value.is-bool-by-key", (void *)&stappler_wasm_data_method_value_is_bool_by_key, "(i*~)i", NULL},
    1652             :         NativeSymbol{"[method]value.is-integer-by-key", (void *)&stappler_wasm_data_method_value_is_integer_by_key, "(i*~)i", NULL},
    1653             :         NativeSymbol{"[method]value.is-double-by-key", (void *)&stappler_wasm_data_method_value_is_double_by_key, "(i*~)i", NULL},
    1654             :         NativeSymbol{"[method]value.is-string-by-key", (void *)&stappler_wasm_data_method_value_is_string_by_key, "(i*~)i", NULL},
    1655             :         NativeSymbol{"[method]value.is-bytes-by-key", (void *)&stappler_wasm_data_method_value_is_bytes_by_key, "(i*~)i", NULL},
    1656             :         NativeSymbol{"[method]value.get-type-by-key", (void *)&stappler_wasm_data_method_value_get_type_by_key, "(i*~)i", NULL},
    1657             :         NativeSymbol{"[method]value.has-value-by-key", (void *)&stappler_wasm_data_method_value_has_value_by_key, "(i*~)i", NULL},
    1658             : 
    1659             :         NativeSymbol{"[method]value.get-integer", (void *)&stappler_wasm_data_method_value_get_integer, "(iI)I", NULL},
    1660             :         NativeSymbol{"[method]value.get-double", (void *)&stappler_wasm_data_method_value_get_double, "(iF)F", NULL},
    1661             :         NativeSymbol{"[method]value.get-bool", (void *)&stappler_wasm_data_method_value_get_bool, "(i)i", NULL},
    1662             :         NativeSymbol{"[method]value.get-string", (void *)&stappler_wasm_data_method_value_get_string, "(i*)", NULL},
    1663             :         NativeSymbol{"[method]value.get-bytes", (void *)&stappler_wasm_data_method_value_get_bytes, "(i*)", NULL},
    1664             :         NativeSymbol{"[method]value.foreach-array", (void *)&stappler_wasm_data_method_value_foreach_array, "(iii)i", NULL},
    1665             :         NativeSymbol{"[method]value.foreach-dict", (void *)&stappler_wasm_data_method_value_foreach_dict, "(iii)i", NULL},
    1666             :         NativeSymbol{"[method]value.get-value-by-idx", (void *)&stappler_wasm_data_method_value_get_value_by_idx, "(ii)i", NULL},
    1667             :         NativeSymbol{"[method]value.get-integer-by-idx", (void *)&stappler_wasm_data_method_value_get_integer_by_idx, "(iiI)I", NULL},
    1668             :         NativeSymbol{"[method]value.get-double-by-idx", (void *)&stappler_wasm_data_method_value_get_double_by_idx, "(iiF)F", NULL},
    1669             :         NativeSymbol{"[method]value.get-bool-by-idx", (void *)&stappler_wasm_data_method_value_get_bool_by_idx, "(ii)i", NULL},
    1670             :         NativeSymbol{"[method]value.get-string-by-idx", (void *)&stappler_wasm_data_method_value_get_string_by_idx, "(ii*)", NULL},
    1671             :         NativeSymbol{"[method]value.get-bytes-by-idx", (void *)&stappler_wasm_data_method_value_get_bytes_by_idx, "(ii*)", NULL},
    1672             :         NativeSymbol{"[method]value.foreach-array-by-idx", (void *)&stappler_wasm_data_method_value_foreach_array_by_idx, "(iiii)i", NULL},
    1673             :         NativeSymbol{"[method]value.foreach-dict-by-idx", (void *)&stappler_wasm_data_method_value_foreach_dict_by_idx, "(iiii)i", NULL},
    1674             :         NativeSymbol{"[method]value.get-value-by-key", (void *)&stappler_wasm_data_method_value_get_value_by_key, "(i*~)i", NULL},
    1675             :         NativeSymbol{"[method]value.get-integer-by-key", (void *)&stappler_wasm_data_method_value_get_integer_by_key, "(i*~I)I", NULL},
    1676             :         NativeSymbol{"[method]value.get-double-by-key", (void *)&stappler_wasm_data_method_value_get_double_by_key, "(i*~F)F", NULL},
    1677             :         NativeSymbol{"[method]value.get-bool-by-key", (void *)&stappler_wasm_data_method_value_get_bool_by_key, "(i*~)i", NULL},
    1678             :         NativeSymbol{"[method]value.get-string-by-key", (void *)&stappler_wasm_data_method_value_get_string_by_key, "(i*~*)", NULL},
    1679             :         NativeSymbol{"[method]value.get-bytes-by-key", (void *)&stappler_wasm_data_method_value_get_bytes_by_key, "(i*~*)", NULL},
    1680             :         NativeSymbol{"[method]value.foreach-array-by-key", (void *)&stappler_wasm_data_method_value_foreach_array_by_key, "(i*~ii)i", NULL},
    1681             :         NativeSymbol{"[method]value.foreach-dict-by-key", (void *)&stappler_wasm_data_method_value_foreach_dict_by_key, "(i*~ii)i", NULL},
    1682             : 
    1683             :         NativeSymbol{"[method]value.set-null", (void *)&stappler_wasm_data_method_value_set_null, "(i)", NULL},
    1684             :         NativeSymbol{"[method]value.set-bool", (void *)&stappler_wasm_data_method_value_set_bool, "(ii)", NULL},
    1685             :         NativeSymbol{"[method]value.set-integer", (void *)&stappler_wasm_data_method_value_set_integer, "(iI)", NULL},
    1686             :         NativeSymbol{"[method]value.set-double", (void *)&stappler_wasm_data_method_value_set_double, "(iF)", NULL},
    1687             :         NativeSymbol{"[method]value.set-string", (void *&)stappler_wasm_data_method_value_set_string, "(i*~)", NULL},
    1688             :         NativeSymbol{"[method]value.set-bytes", (void *)&stappler_wasm_data_method_value_set_bytes, "(i*~)", NULL},
    1689             :         NativeSymbol{"[method]value.set-dict", (void *)&stappler_wasm_data_method_value_set_dict, "(i)", NULL},
    1690             :         NativeSymbol{"[method]value.set-array", (void *)&stappler_wasm_data_method_value_set_array, "(i)", NULL},
    1691             :         NativeSymbol{"[method]value.set-value-copy", (void *)&stappler_wasm_data_method_value_set_value_copy, "(ii)", NULL},
    1692             :         NativeSymbol{"[method]value.set-null-for-idx", (void *)&stappler_wasm_data_method_value_set_null_for_idx, "(ii)", NULL},
    1693             :         NativeSymbol{"[method]value.set-bool-for-idx", (void *)&stappler_wasm_data_method_value_set_bool_for_idx, "(iii)", NULL},
    1694             :         NativeSymbol{"[method]value.set-integer-for-idx", (void *)&stappler_wasm_data_method_value_set_integer_for_idx, "(iIi)", NULL},
    1695             :         NativeSymbol{"[method]value.set-double-for-idx", (void *)&stappler_wasm_data_method_value_set_double_for_idx, "(iFi)", NULL},
    1696             :         NativeSymbol{"[method]value.set-string-for-idx", (void *)&stappler_wasm_data_method_value_set_string_for_idx, "(i*~i)", NULL},
    1697             :         NativeSymbol{"[method]value.set-bytes-for-idx", (void *)&stappler_wasm_data_method_value_set_bytes_for_idx, "(i*~i)", NULL},
    1698             :         NativeSymbol{"[method]value.set-dict-for-idx", (void *)&stappler_wasm_data_method_value_set_dict_for_idx, "(ii)i", NULL},
    1699             :         NativeSymbol{"[method]value.set-array-for-idx", (void *)&stappler_wasm_data_method_value_set_array_for_idx, "(ii)i", NULL},
    1700             :         NativeSymbol{"[method]value.set-value-for-idx", (void *)&stappler_wasm_data_method_value_set_value_for_idx, "(ii)i", NULL},
    1701             :         NativeSymbol{"[method]value.set-value-copy-for-idx", (void *)&stappler_wasm_data_method_value_set_value_copy_for_idx, "(iii)i", NULL},
    1702             :         NativeSymbol{"[method]value.set-null-for-key", (void *)&stappler_wasm_data_method_value_set_null_for_key, "(i*~)", NULL},
    1703             :         NativeSymbol{"[method]value.set-bool-for-key", (void *)&stappler_wasm_data_method_value_set_bool_for_key, "(ii*~)", NULL},
    1704             :         NativeSymbol{"[method]value.set-integer-for-key", (void *)&stappler_wasm_data_method_value_set_integer_for_key, "(iI*~)", NULL},
    1705             :         NativeSymbol{"[method]value.set-double-for-key", (void *)&stappler_wasm_data_method_value_set_double_for_key, "(iF*~)", NULL},
    1706             :         NativeSymbol{"[method]value.set-string-for-key", (void *)&stappler_wasm_data_method_value_set_string_for_key, "(i*~*~)", NULL},
    1707             :         NativeSymbol{"[method]value.set-bytes-for-key", (void *)&stappler_wasm_data_method_value_set_bytes_for_key, "(i*~*~)", NULL},
    1708             :         NativeSymbol{"[method]value.set-dict-for-key", (void *)&stappler_wasm_data_method_value_set_dict_for_key, "(i*~)i", NULL},
    1709             :         NativeSymbol{"[method]value.set-array-for-key", (void *)&stappler_wasm_data_method_value_set_array_for_key, "(i*~)i", NULL},
    1710             :         NativeSymbol{"[method]value.set-value-for-key", (void *)&stappler_wasm_data_method_value_set_value_for_key, "(i*~)i", NULL},
    1711             :         NativeSymbol{"[method]value.set-value-copy-for-key", (void *)&stappler_wasm_data_method_value_set_value_copy_for_key, "(ii*~)i", NULL},
    1712             :         NativeSymbol{"[method]value.add-null", (void *)&stappler_wasm_data_method_value_add_null, "(i)", NULL},
    1713             :         NativeSymbol{"[method]value.add-bool", (void *)&stappler_wasm_data_method_value_add_bool, "(ii)", NULL},
    1714             :         NativeSymbol{"[method]value.add-integer", (void *)&stappler_wasm_data_method_value_add_integer, "(iI)", NULL},
    1715             :         NativeSymbol{"[method]value.add-double", (void *)&stappler_wasm_data_method_value_add_double, "(iF)", NULL},
    1716             :         NativeSymbol{"[method]value.add-string", (void *)&stappler_wasm_data_method_value_add_string, "(i*~)", NULL},
    1717             :         NativeSymbol{"[method]value.add-bytes", (void *)&stappler_wasm_data_method_value_add_bytes, "(i*~)", NULL},
    1718             :         NativeSymbol{"[method]value.add-dict", (void *)&stappler_wasm_data_method_value_add_dict, "(i)i", NULL},
    1719             :         NativeSymbol{"[method]value.add-array", (void *)&stappler_wasm_data_method_value_add_array, "(i)i", NULL},
    1720             :         NativeSymbol{"[method]value.add-value", (void *)&stappler_wasm_data_method_value_add_value, "(i)i", NULL},
    1721             :         NativeSymbol{"[method]value.add-value-copy", (void *)&stappler_wasm_data_method_value_add_value_copy, "(ii)i", NULL},
    1722             :         NativeSymbol{"[method]value.erase-for-idx", (void *)&stappler_wasm_data_method_value_erase_for_idx, "(ii)i", NULL},
    1723             :         NativeSymbol{"[method]value.erase-for-key", (void *)&stappler_wasm_data_method_value_erase_for_key, "(i*~)i", NULL},
    1724             :         NativeSymbol{"[method]value.is-equal", (void *)&stappler_wasm_data_method_value_is_equal, "(ii)i", NULL},
    1725             :         NativeSymbol{"[method]value.is-not-equal", (void *)&stappler_wasm_data_method_value_is_not_equal, "(ii)i", NULL},
    1726             : 
    1727             :         NativeSymbol{"[resource-drop]value", (void *)&StapplerDataDrop, "(i)", NULL}
    1728             : };
    1729             : 
    1730             : static NativeModule s_dataModule("stappler:wasm/data", stapper_data_symbols, sizeof(stapper_data_symbols) / sizeof(NativeSymbol));
    1731             : 
    1732             : }

Generated by: LCOV version 1.14