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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b4d7480c6b1b4e19069530f4a5d309b6910bac84cad7568822ebe7076d94882
4
- data.tar.gz: 0f91d9185b6b041423f88a2132a9b2deef33d9edc15de2c3154a6349a5d56395
3
+ metadata.gz: 4a2c456cd81f2a2d5085e720a1872ffc7ee873c49319db8fc0459f2c6336e437
4
+ data.tar.gz: a2881627264f8d69bdf04f3773630f17eacd9c03d5fbaa59c521ce7590ff3778
5
5
  SHA512:
6
- metadata.gz: 6da0a208160323f8d5ca6d1327a7d2adffd3317b414a771c7bf6c8449dd0e08337d05c87ff4f5d29a2c6cda28fd09a425e40b33e0f5f3a81d6deb4061c841439
7
- data.tar.gz: 6eac8c22d39f16abb5e47e7d4b8b8423e16b4c6fc9b584ab582325f201b6b390a6f20638b5619abab1f8f0222c4e670321b01784aad72bcb73710558004a2d84
6
+ metadata.gz: 1733ef77baf22132775c06ea988ad66f8e29712a92221513894ab31173fcd165edfa6ca2a32ca855ba5d641abda6613a0419f34baf32a59a47886b98385b4836
7
+ data.tar.gz: 910f2e1d364f873261a3a4caa092427101dd64bfeaefb497fafc6caa64dd5ae4fc2d42559f31829a350d7329bef3f887f557afe1449e934516ed10d7e638b25a
@@ -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 j_global = JS_GetGlobalObject(ctx);
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, j_strigified);
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, j_strigified);
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
- rb_ary_push(r_argv, to_rb_value(ctx, argv[i]));
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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quickjs
4
- VERSION = "0.6.2"
4
+ VERSION = "0.6.4"
5
5
  end
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.2
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-24 00:00:00.000000000 Z
11
+ date: 2025-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json