quickjs 0.8.0 → 0.8.1
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 -4
- 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: a7de66a3eb1ddd2b9ab50dcbf88f083e42466a8b91343a79af6f01b847d99d01
|
4
|
+
data.tar.gz: f0bab5aa5a676731737633e67c463572dc5b52f959bf9f897883f0034927d314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52f0a7a7419f0b7bb3cb1efb0f6b33442b7446d95cee7567dcb5e959c0ccdbf12ceaa02144e1d66730e411eba734bfd06923b1f2ce83b5d96611bb11c6e49964
|
7
|
+
data.tar.gz: 9f32de511d5dfcaff34dc2cf63970743d8d933286a617178e188bc2d56407159b694af92f7a5466c32a69a618a25f1c365d10a435051e7a05b588a750e9f5a7c
|
data/ext/quickjsrb/quickjsrb.c
CHANGED
@@ -311,7 +311,7 @@ static JSValue js_quickjsrb_call_global(JSContext *ctx, JSValueConst _this, int
|
|
311
311
|
const char *funcName = JS_ToCString(ctx, func_data[0]);
|
312
312
|
|
313
313
|
VMData *data = JS_GetContextOpaque(ctx);
|
314
|
-
VALUE r_proc = rb_hash_aref(data->defined_functions,
|
314
|
+
VALUE r_proc = rb_hash_aref(data->defined_functions, ID2SYM(rb_intern(funcName)));
|
315
315
|
// Shouldn't happen
|
316
316
|
if (r_proc == Qnil)
|
317
317
|
{
|
@@ -628,11 +628,19 @@ static VALUE vm_m_defineGlobalFunction(int argc, VALUE *argv, VALUE r_self)
|
|
628
628
|
VALUE r_block;
|
629
629
|
rb_scan_args(argc, argv, "10*&", &r_name, &r_flags, &r_block);
|
630
630
|
|
631
|
+
if (!(SYMBOL_P(r_name) || RB_TYPE_P(r_name, T_STRING)))
|
632
|
+
{
|
633
|
+
rb_raise(rb_eTypeError, "function's name should be a Symbol or a String");
|
634
|
+
}
|
635
|
+
|
631
636
|
VMData *data;
|
632
637
|
TypedData_Get_Struct(r_self, VMData, &vm_type, data);
|
633
638
|
|
634
|
-
|
635
|
-
|
639
|
+
VALUE r_name_sym = rb_funcall(r_name, rb_intern("to_sym"), 0);
|
640
|
+
|
641
|
+
rb_hash_aset(data->defined_functions, r_name_sym, r_block);
|
642
|
+
VALUE r_name_str = rb_funcall(r_name, rb_intern("to_s"), 0);
|
643
|
+
char *funcName = StringValueCStr(r_name_str);
|
636
644
|
|
637
645
|
JSValueConst ruby_data[2];
|
638
646
|
ruby_data[0] = JS_NewString(data->context, funcName);
|
@@ -646,7 +654,7 @@ static VALUE vm_m_defineGlobalFunction(int argc, VALUE *argv, VALUE r_self)
|
|
646
654
|
JS_FreeValue(data->context, ruby_data[0]);
|
647
655
|
JS_FreeValue(data->context, ruby_data[1]);
|
648
656
|
|
649
|
-
return
|
657
|
+
return r_name_sym;
|
650
658
|
}
|
651
659
|
|
652
660
|
static VALUE vm_m_import(int argc, VALUE *argv, VALUE r_self)
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hmsk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|