quickjs 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/quickjsrb/quickjsrb.c +12 -11
- data/lib/quickjs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2c456cd81f2a2d5085e720a1872ffc7ee873c49319db8fc0459f2c6336e437
|
4
|
+
data.tar.gz: a2881627264f8d69bdf04f3773630f17eacd9c03d5fbaa59c521ce7590ff3778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1733ef77baf22132775c06ea988ad66f8e29712a92221513894ab31173fcd165edfa6ca2a32ca855ba5d641abda6613a0419f34baf32a59a47886b98385b4836
|
7
|
+
data.tar.gz: 910f2e1d364f873261a3a4caa092427101dd64bfeaefb497fafc6caa64dd5ae4fc2d42559f31829a350d7329bef3f887f557afe1449e934516ed10d7e638b25a
|
data/ext/quickjsrb/quickjsrb.c
CHANGED
@@ -101,6 +101,10 @@ VALUE find_ruby_error(JSContext *ctx, JSValue j_error)
|
|
101
101
|
return rb_funcall(rb_const_get(rb_cClass, rb_intern("ObjectSpace")), rb_intern("_id2ref"), 1, INT2NUM(errorOriginalRubyObjectId));
|
102
102
|
}
|
103
103
|
}
|
104
|
+
else
|
105
|
+
{
|
106
|
+
JS_FreeValue(ctx, j_errorOriginalRubyObjectId);
|
107
|
+
}
|
104
108
|
return Qnil;
|
105
109
|
}
|
106
110
|
|
@@ -111,19 +115,13 @@ VALUE r_try_json_parse(VALUE r_str)
|
|
111
115
|
|
112
116
|
VALUE to_r_json(JSContext *ctx, JSValue j_val)
|
113
117
|
{
|
114
|
-
JSValue
|
115
|
-
JSValue j_jsonClass = JS_GetPropertyStr(ctx, j_global, "JSON");
|
116
|
-
JSValue j_stringifyFunc = JS_GetPropertyStr(ctx, j_jsonClass, "stringify");
|
117
|
-
JSValue j_strigified = JS_Call(ctx, j_stringifyFunc, j_jsonClass, 1, (JSValueConst *)&j_val);
|
118
|
+
JSValue j_stringified = JS_JSONStringify(ctx, j_val, JS_UNDEFINED, JS_UNDEFINED);
|
118
119
|
|
119
|
-
const char *msg = JS_ToCString(ctx,
|
120
|
+
const char *msg = JS_ToCString(ctx, j_stringified);
|
120
121
|
VALUE r_str = rb_str_new2(msg);
|
121
122
|
JS_FreeCString(ctx, msg);
|
122
123
|
|
123
|
-
JS_FreeValue(ctx,
|
124
|
-
JS_FreeValue(ctx, j_stringifyFunc);
|
125
|
-
JS_FreeValue(ctx, j_jsonClass);
|
126
|
-
JS_FreeValue(ctx, j_global);
|
124
|
+
JS_FreeValue(ctx, j_stringified);
|
127
125
|
|
128
126
|
return r_str;
|
129
127
|
}
|
@@ -339,7 +337,9 @@ static JSValue js_quickjsrb_call_global(JSContext *ctx, JSValueConst _this, int
|
|
339
337
|
VALUE r_argv = rb_ary_new();
|
340
338
|
for (int i = 0; i < argc; i++)
|
341
339
|
{
|
342
|
-
|
340
|
+
JSValue j_v = JS_DupValue(ctx, argv[i]);
|
341
|
+
rb_ary_push(r_argv, to_rb_value(ctx, j_v));
|
342
|
+
JS_FreeValue(ctx, j_v);
|
343
343
|
}
|
344
344
|
rb_ary_push(r_call_args, r_argv);
|
345
345
|
rb_ary_push(r_call_args, ULONG2NUM(data->eval_time->limit * 1000 / CLOCKS_PER_SEC));
|
@@ -399,11 +399,12 @@ static JSValue js_quickjsrb_log(JSContext *ctx, JSValueConst _this, int argc, JS
|
|
399
399
|
VALUE r_row = rb_ary_new();
|
400
400
|
for (int i = 0; i < argc; i++)
|
401
401
|
{
|
402
|
-
JSValue j_logged = argv[i];
|
402
|
+
JSValue j_logged = JS_DupValue(ctx, argv[i]);
|
403
403
|
VALUE r_raw = JS_VALUE_GET_NORM_TAG(j_logged) == JS_TAG_OBJECT && JS_PromiseState(ctx, j_logged) != -1 ? rb_str_new2("Promise") : to_rb_value(ctx, j_logged);
|
404
404
|
const char *body = JS_ToCString(ctx, j_logged);
|
405
405
|
VALUE r_c = rb_str_new2(body);
|
406
406
|
JS_FreeCString(ctx, body);
|
407
|
+
JS_FreeValue(ctx, j_logged);
|
407
408
|
|
408
409
|
rb_ary_push(r_row, r_log_body_new(r_raw, r_c));
|
409
410
|
}
|
data/lib/quickjs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hmsk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|