int w_LocalStorage_prototype_removeItem(duk_context *ctx) { const char *key = duk_require_string(ctx, 0); duk_push_this(ctx); /* this */ duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */ duk_del_prop_string(ctx, -1, key); /* this, __MURAL_DATA__ */ LocalStorage *inst = getNativePointer<LocalStorage>(ctx); duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */ inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */ duk_pop_2(ctx); return 0; }
int w_LocalStorage_prototype_setItem(duk_context *ctx) { const char *key = duk_require_string(ctx, 0); // Make sure value is string duk_to_string(ctx, 1); const char *value = duk_require_string(ctx, 1); duk_push_this(ctx); /* this */ duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */ duk_push_string(ctx, value); /* this, __MURAL_DATA__, value */ duk_put_prop_string(ctx, -2, key); /* this, __MURAL_DATA__ */ LocalStorage *inst = getNativePointer<LocalStorage>(ctx); duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */ inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */ duk_pop_2(ctx); return 0; }