script_core 0.2.2 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +41 -45
- data/.travis.yml +2 -1
- data/Gemfile +3 -3
- data/README.md +7 -1
- data/bootstrap.sh +2 -2
- data/ext/enterprise_script_service/libseccomp/.travis.yml +24 -12
- data/ext/enterprise_script_service/libseccomp/CHANGELOG +32 -0
- data/ext/enterprise_script_service/libseccomp/CONTRIBUTING.md +37 -26
- data/ext/enterprise_script_service/libseccomp/CREDITS +11 -0
- data/ext/enterprise_script_service/libseccomp/README.md +21 -1
- data/ext/enterprise_script_service/libseccomp/configure.ac +13 -8
- data/ext/enterprise_script_service/libseccomp/doc/Makefile.am +6 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_api_get.3 +12 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_arch_add.3 +38 -6
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_attr_set.3 +53 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_export_bpf.3 +20 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_init.3 +9 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_load.3 +32 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_merge.3 +16 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_alloc.3 +113 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_fd.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_free.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_id_valid.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_receive.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_respond.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_rule_add.3 +64 -3
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_syscall_priority.3 +18 -3
- data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +19 -0
- data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +116 -0
- data/ext/enterprise_script_service/libseccomp/src/.gitignore +2 -0
- data/ext/enterprise_script_service/libseccomp/src/Makefile.am +31 -17
- data/ext/enterprise_script_service/libseccomp/src/api.c +254 -58
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-arm.c +47 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-arm.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-gperf-generate +40 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-mips.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64.h +3 -11
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc.h +1 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.c +3 -3
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.h +29 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.c +606 -8
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.c +31 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.h +22 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +171 -12
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.h +1 -17
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +166 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.h +1 -20
- data/ext/enterprise_script_service/libseccomp/src/arch-syscall-dump.c +8 -1
- data/ext/enterprise_script_service/libseccomp/src/arch-syscall-validate +359 -143
- data/ext/enterprise_script_service/libseccomp/src/arch-x32.c +36 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-x32.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +172 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.h +1 -14
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch.c +11 -3
- data/ext/enterprise_script_service/libseccomp/src/arch.h +7 -0
- data/ext/enterprise_script_service/libseccomp/src/db.c +268 -57
- data/ext/enterprise_script_service/libseccomp/src/db.h +16 -2
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +503 -148
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.h +2 -1
- data/ext/enterprise_script_service/libseccomp/src/gen_pfc.c +165 -37
- data/ext/enterprise_script_service/libseccomp/src/python/libseccomp.pxd +37 -1
- data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +295 -5
- data/ext/enterprise_script_service/libseccomp/src/syscalls.c +56 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.csv +470 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.h +62 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.perf.template +82 -0
- data/ext/enterprise_script_service/libseccomp/src/system.c +196 -16
- data/ext/enterprise_script_service/libseccomp/src/system.h +68 -13
- data/ext/enterprise_script_service/libseccomp/tests/.gitignore +10 -2
- data/ext/enterprise_script_service/libseccomp/tests/06-sim-actions.tests +1 -1
- data/ext/enterprise_script_service/libseccomp/tests/11-basic-basic_errors.c +5 -5
- data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.c +35 -1
- data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.py +10 -1
- data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +4 -3
- data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.c +12 -0
- data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.c → 18-sim-basic_allowlist.c} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.py → 18-sim-basic_allowlist.py} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_allowlist.tests +32 -0
- data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.tests +33 -17
- data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.c → 34-sim-basic_denylist.c} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.py → 34-sim-basic_denylist.py} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_denylist.tests +32 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.tests +25 -25
- data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.c +24 -3
- data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.py +16 -1
- data/ext/enterprise_script_service/libseccomp/tests/47-live-kill_process.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.c +112 -0
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.py +60 -0
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.c +156 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.py +95 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.tests +65 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.c +128 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.py +95 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.c +134 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.sh +46 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.c +90 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.py +65 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.c +64 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.py +46 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.c +116 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.py +61 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +34 -10
- data/ext/enterprise_script_service/libseccomp/tests/regression +10 -3
- data/ext/enterprise_script_service/libseccomp/tests/util.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
- data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -1
- data/ext/enterprise_script_service/libseccomp/tools/scmp_arch_detect.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_disasm.c +4 -2
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +4 -0
- data/ext/enterprise_script_service/libseccomp/tools/util.c +14 -12
- data/ext/enterprise_script_service/libseccomp/tools/util.h +7 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +106 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +51 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +24 -0
- data/ext/enterprise_script_service/mruby/.gitignore +3 -0
- data/ext/enterprise_script_service/mruby/.travis.yml +6 -9
- data/ext/enterprise_script_service/mruby/AUTHORS +1 -0
- data/ext/enterprise_script_service/mruby/Doxyfile +1 -1
- data/ext/enterprise_script_service/mruby/LICENSE +1 -1
- data/ext/enterprise_script_service/mruby/README.md +6 -2
- data/ext/enterprise_script_service/mruby/appveyor.yml +9 -12
- data/ext/enterprise_script_service/mruby/appveyor_config.rb +9 -0
- data/ext/enterprise_script_service/mruby/build_config.rb +6 -6
- data/ext/enterprise_script_service/mruby/doc/guides/compile.md +6 -2
- data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
- data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +4 -8
- data/ext/enterprise_script_service/mruby/doc/limitations.md +10 -10
- data/ext/enterprise_script_service/mruby/doc/opcode.md +108 -95
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_ArduinoDue.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelEdison.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelGalileo.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_RX630.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_chipKITMax32.rb +2 -2
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_dreamcast_shelf.rb +108 -0
- data/ext/enterprise_script_service/mruby/include/mrbconf.h +10 -7
- data/ext/enterprise_script_service/mruby/include/mruby.h +24 -9
- data/ext/enterprise_script_service/mruby/include/mruby/array.h +4 -0
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +11 -2
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +0 -10
- data/ext/enterprise_script_service/mruby/include/mruby/common.h +10 -0
- data/ext/enterprise_script_service/mruby/include/mruby/compile.h +11 -3
- data/ext/enterprise_script_service/mruby/include/mruby/dump.h +1 -17
- data/ext/enterprise_script_service/mruby/include/mruby/irep.h +10 -0
- data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
- data/ext/enterprise_script_service/mruby/include/mruby/khash.h +23 -5
- data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +1 -0
- data/ext/enterprise_script_service/mruby/include/mruby/ops.h +3 -2
- data/ext/enterprise_script_service/mruby/include/mruby/proc.h +13 -8
- data/ext/enterprise_script_service/mruby/include/mruby/string.h +2 -1
- data/ext/enterprise_script_service/mruby/include/mruby/value.h +32 -41
- data/ext/enterprise_script_service/mruby/include/mruby/version.h +4 -4
- data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +2 -30
- data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +21 -46
- data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +9 -0
- data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
- data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +7 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +0 -31
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +5 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +5 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +5 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +7 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +24 -21
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +6 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +6 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +76 -48
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +107 -32
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13153 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +13 -15
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +3 -214
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +3 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +7 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +77 -32
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +18 -36
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +324 -122
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +18 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +32 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +57 -49
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +6 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +15 -17
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +9 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +4 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +3 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +113 -10
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +6 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +9 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +62 -25
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +5 -23
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +4 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +5 -11
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +1 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +11 -15
- data/ext/enterprise_script_service/mruby/mrblib/00class.rb +10 -0
- data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -3
- data/ext/enterprise_script_service/mruby/src/array.c +25 -11
- data/ext/enterprise_script_service/mruby/src/backtrace.c +2 -2
- data/ext/enterprise_script_service/mruby/src/class.c +48 -32
- data/ext/enterprise_script_service/mruby/src/codedump.c +4 -0
- data/ext/enterprise_script_service/mruby/src/debug.c +8 -5
- data/ext/enterprise_script_service/mruby/src/dump.c +3 -65
- data/ext/enterprise_script_service/mruby/src/error.c +58 -7
- data/ext/enterprise_script_service/mruby/src/etc.c +13 -5
- data/ext/enterprise_script_service/mruby/src/fmt_fp.c +98 -21
- data/ext/enterprise_script_service/mruby/src/gc.c +15 -280
- data/ext/enterprise_script_service/mruby/src/hash.c +13 -21
- data/ext/enterprise_script_service/mruby/src/kernel.c +6 -9
- data/ext/enterprise_script_service/mruby/src/load.c +56 -30
- data/ext/enterprise_script_service/mruby/src/numeric.c +50 -70
- data/ext/enterprise_script_service/mruby/src/object.c +23 -5
- data/ext/enterprise_script_service/mruby/src/print.c +27 -3
- data/ext/enterprise_script_service/mruby/src/proc.c +26 -7
- data/ext/enterprise_script_service/mruby/src/range.c +4 -12
- data/ext/enterprise_script_service/mruby/src/state.c +34 -11
- data/ext/enterprise_script_service/mruby/src/string.c +93 -56
- data/ext/enterprise_script_service/mruby/src/symbol.c +13 -12
- data/ext/enterprise_script_service/mruby/src/vm.c +48 -53
- data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +19 -22
- data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +1 -1
- data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
- data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +3 -3
- data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +6 -6
- data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +8 -8
- data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
- data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
- data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
- data/ext/enterprise_script_service/mruby/test/t/kernel.rb +15 -24
- data/ext/enterprise_script_service/mruby/travis_config.rb +0 -14
- data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
- data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
- data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
- data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
- data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
- data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
- data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
- data/ext/enterprise_script_service/msgpack/README.md +3 -2
- data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
- data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
- data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
- data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
- data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
- data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
- data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
- data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
- data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
- data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
- data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
- data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
- data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
- data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
- data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
- data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
- data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
- data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
- data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
- data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
- data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
- data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
- data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
- data/lib/script_core/engine.rb +24 -5
- data/lib/script_core/executable.rb +4 -3
- data/lib/script_core/result.rb +1 -5
- data/lib/script_core/service_channel.rb +1 -0
- data/lib/script_core/version.rb +1 -1
- data/lib/tasks/script_core.rake +3 -1
- data/script_core.gemspec +2 -2
- data/spec/dummy/app/lib/script_engine.rb +64 -5
- metadata +68 -30
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +0 -570
- data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +0 -542
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +0 -626
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +0 -626
- data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +0 -558
- data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +0 -692
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_whitelist.tests +0 -32
- data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_blacklist.tests +0 -32
- data/ext/enterprise_script_service/msgpack/.travis.yml +0 -258
@@ -47,6 +47,17 @@ mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
|
|
47
47
|
mrb_value result;
|
48
48
|
|
49
49
|
if (mrb_obj_eq(mrb, obj1, obj2)) return TRUE;
|
50
|
+
#ifndef MRB_WITHOUT_FLOAT
|
51
|
+
/* value mixing with integer and float */
|
52
|
+
if (mrb_fixnum_p(obj1)) {
|
53
|
+
if (mrb_float_p(obj2) && (mrb_float)mrb_fixnum(obj1) == mrb_float(obj2))
|
54
|
+
return TRUE;
|
55
|
+
}
|
56
|
+
else if (mrb_float_p(obj1)) {
|
57
|
+
if (mrb_fixnum_p(obj2) && mrb_float(obj1) == (mrb_float)mrb_fixnum(obj2))
|
58
|
+
return TRUE;
|
59
|
+
}
|
60
|
+
#endif
|
50
61
|
result = mrb_funcall(mrb, obj1, "==", 1, obj2);
|
51
62
|
if (mrb_test(result)) return TRUE;
|
52
63
|
return FALSE;
|
@@ -83,13 +94,17 @@ mrb_true(mrb_state *mrb, mrb_value obj)
|
|
83
94
|
static mrb_value
|
84
95
|
nil_to_s(mrb_state *mrb, mrb_value obj)
|
85
96
|
{
|
86
|
-
|
97
|
+
mrb_value str = mrb_str_new_frozen(mrb, 0, 0);
|
98
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
99
|
+
return str;
|
87
100
|
}
|
88
101
|
|
89
102
|
static mrb_value
|
90
103
|
nil_inspect(mrb_state *mrb, mrb_value obj)
|
91
104
|
{
|
92
|
-
|
105
|
+
mrb_value str = mrb_str_new_lit_frozen(mrb, "nil");
|
106
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
107
|
+
return str;
|
93
108
|
}
|
94
109
|
|
95
110
|
/***********************************************************************
|
@@ -150,7 +165,9 @@ true_xor(mrb_state *mrb, mrb_value obj)
|
|
150
165
|
static mrb_value
|
151
166
|
true_to_s(mrb_state *mrb, mrb_value obj)
|
152
167
|
{
|
153
|
-
|
168
|
+
mrb_value str = mrb_str_new_lit_frozen(mrb, "true");
|
169
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
170
|
+
return str;
|
154
171
|
}
|
155
172
|
|
156
173
|
/* 15.2.5.3.4 */
|
@@ -257,7 +274,9 @@ false_or(mrb_state *mrb, mrb_value obj)
|
|
257
274
|
static mrb_value
|
258
275
|
false_to_s(mrb_state *mrb, mrb_value obj)
|
259
276
|
{
|
260
|
-
|
277
|
+
mrb_value str = mrb_str_new_lit_frozen(mrb, "false");
|
278
|
+
RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
|
279
|
+
return str;
|
261
280
|
}
|
262
281
|
|
263
282
|
void
|
@@ -358,7 +377,6 @@ static const struct types {
|
|
358
377
|
{MRB_TT_STRING, "String"},
|
359
378
|
{MRB_TT_RANGE, "Range"},
|
360
379
|
/* {MRB_TT_BIGNUM, "Bignum"}, */
|
361
|
-
{MRB_TT_FILE, "File"},
|
362
380
|
{MRB_TT_DATA, "Data"}, /* internal use: wrapped C pointers */
|
363
381
|
/* {MRB_TT_VARMAP, "Varmap"}, */ /* internal use: dynamic variables */
|
364
382
|
/* {MRB_TT_NODE, "Node"}, */ /* internal use: syntax tree node */
|
@@ -7,24 +7,48 @@
|
|
7
7
|
#include <mruby.h>
|
8
8
|
#include <mruby/string.h>
|
9
9
|
#include <mruby/variable.h>
|
10
|
+
#include <mruby/error.h>
|
11
|
+
#include <string.h>
|
10
12
|
|
11
13
|
#ifndef MRB_DISABLE_STDIO
|
14
|
+
static void
|
15
|
+
printcstr(const char *str, size_t len, FILE *stream)
|
16
|
+
{
|
17
|
+
if (str) {
|
18
|
+
fwrite(str, len, 1, stream);
|
19
|
+
putc('\n', stream);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
12
23
|
static void
|
13
24
|
printstr(mrb_value obj, FILE *stream)
|
14
25
|
{
|
15
26
|
if (mrb_string_p(obj)) {
|
16
|
-
|
17
|
-
putc('\n', stream);
|
27
|
+
printcstr(RSTRING_PTR(obj), RSTRING_LEN(obj), stream);
|
18
28
|
}
|
19
29
|
}
|
20
30
|
#else
|
31
|
+
# define printcstr(str, len, stream) (void)0
|
21
32
|
# define printstr(obj, stream) (void)0
|
22
33
|
#endif
|
23
34
|
|
35
|
+
void
|
36
|
+
mrb_core_init_printabort(void)
|
37
|
+
{
|
38
|
+
static const char *str = "Failed mruby core initialization";
|
39
|
+
printcstr(str, strlen(str), stdout);
|
40
|
+
}
|
41
|
+
|
24
42
|
MRB_API void
|
25
43
|
mrb_p(mrb_state *mrb, mrb_value obj)
|
26
44
|
{
|
27
|
-
|
45
|
+
if (mrb_type(obj) == MRB_TT_EXCEPTION && mrb_obj_ptr(obj) == mrb->nomem_err) {
|
46
|
+
static const char *str = "Out of memory";
|
47
|
+
printcstr(str, strlen(str), stdout);
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
printstr(mrb_inspect(mrb, obj), stdout);
|
51
|
+
}
|
28
52
|
}
|
29
53
|
|
30
54
|
MRB_API void
|
@@ -8,6 +8,7 @@
|
|
8
8
|
#include <mruby/class.h>
|
9
9
|
#include <mruby/proc.h>
|
10
10
|
#include <mruby/opcode.h>
|
11
|
+
#include <mruby/data.h>
|
11
12
|
|
12
13
|
static const mrb_code call_iseq[] = {
|
13
14
|
OP_CALL,
|
@@ -46,7 +47,7 @@ env_new(mrb_state *mrb, mrb_int nlocals)
|
|
46
47
|
int bidx;
|
47
48
|
|
48
49
|
e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, NULL);
|
49
|
-
|
50
|
+
MRB_ENV_SET_LEN(e, nlocals);
|
50
51
|
bidx = ci->argc;
|
51
52
|
if (ci->argc < 0) bidx = 2;
|
52
53
|
else bidx += 1;
|
@@ -121,8 +122,15 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const
|
|
121
122
|
p->e.env = e = env_new(mrb, argc);
|
122
123
|
p->flags |= MRB_PROC_ENVSET;
|
123
124
|
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)e);
|
124
|
-
|
125
|
+
MRB_ENV_CLOSE(e);
|
126
|
+
|
127
|
+
/* NOTE: Prevents keeping invalid addresses when NoMemoryError is raised from `mrb_malloc()`. */
|
128
|
+
e->stack = NULL;
|
129
|
+
MRB_ENV_SET_LEN(e, 0);
|
130
|
+
|
125
131
|
e->stack = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value) * argc);
|
132
|
+
MRB_ENV_SET_LEN(e, argc);
|
133
|
+
|
126
134
|
if (argv) {
|
127
135
|
for (i = 0; i < argc; ++i) {
|
128
136
|
e->stack[i] = argv[i];
|
@@ -155,9 +163,9 @@ mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx)
|
|
155
163
|
if (!e) {
|
156
164
|
mrb_raise(mrb, E_TYPE_ERROR, "Can't get cfunc env from cfunc Proc without REnv.");
|
157
165
|
}
|
158
|
-
if (idx < 0 ||
|
166
|
+
if (idx < 0 || MRB_ENV_LEN(e) <= idx) {
|
159
167
|
mrb_raisef(mrb, E_INDEX_ERROR, "Env index out of range: %i (expected: 0 <= index < %i)",
|
160
|
-
idx,
|
168
|
+
idx, MRB_ENV_LEN(e));
|
161
169
|
}
|
162
170
|
|
163
171
|
return e->stack[idx];
|
@@ -203,9 +211,8 @@ mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
|
|
203
211
|
static mrb_value
|
204
212
|
mrb_proc_init_copy(mrb_state *mrb, mrb_value self)
|
205
213
|
{
|
206
|
-
mrb_value proc;
|
214
|
+
mrb_value proc = mrb_get_arg1(mrb);
|
207
215
|
|
208
|
-
mrb_get_args(mrb, "o", &proc);
|
209
216
|
if (!mrb_proc_p(proc)) {
|
210
217
|
mrb_raise(mrb, E_ARGUMENT_ERROR, "not a proc");
|
211
218
|
}
|
@@ -286,14 +293,25 @@ mrb_proc_arity(const struct RProc *p)
|
|
286
293
|
return arity;
|
287
294
|
}
|
288
295
|
|
296
|
+
static void
|
297
|
+
tempirep_free(mrb_state *mrb, void *p)
|
298
|
+
{
|
299
|
+
if (p) mrb_irep_free(mrb, (mrb_irep *)p);
|
300
|
+
}
|
301
|
+
|
302
|
+
static const mrb_data_type tempirep_type = { "temporary irep", tempirep_free };
|
303
|
+
|
289
304
|
void
|
290
305
|
mrb_init_proc(mrb_state *mrb)
|
291
306
|
{
|
292
307
|
struct RProc *p;
|
293
308
|
mrb_method_t m;
|
294
|
-
|
309
|
+
struct RData *irep_obj = mrb_data_object_alloc(mrb, mrb->object_class, NULL, &tempirep_type);
|
310
|
+
mrb_irep *call_irep;
|
295
311
|
static const mrb_irep mrb_irep_zero = { 0 };
|
296
312
|
|
313
|
+
call_irep = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
|
314
|
+
irep_obj->data = call_irep;
|
297
315
|
*call_irep = mrb_irep_zero;
|
298
316
|
call_irep->flags = MRB_ISEQ_NO_FREE;
|
299
317
|
call_irep->iseq = call_iseq;
|
@@ -305,6 +323,7 @@ mrb_init_proc(mrb_state *mrb)
|
|
305
323
|
mrb_define_method(mrb, mrb->proc_class, "arity", proc_arity, MRB_ARGS_NONE());
|
306
324
|
|
307
325
|
p = mrb_proc_new(mrb, call_irep);
|
326
|
+
irep_obj->data = NULL;
|
308
327
|
MRB_METHOD_FROM_PROC(m, p);
|
309
328
|
mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "call"), m);
|
310
329
|
mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "[]"), m);
|
@@ -182,11 +182,9 @@ range_eq(mrb_state *mrb, mrb_value range)
|
|
182
182
|
{
|
183
183
|
struct RRange *rr;
|
184
184
|
struct RRange *ro;
|
185
|
-
mrb_value obj;
|
185
|
+
mrb_value obj = mrb_get_arg1(mrb);
|
186
186
|
mrb_bool v1, v2;
|
187
187
|
|
188
|
-
mrb_get_args(mrb, "o", &obj);
|
189
|
-
|
190
188
|
if (mrb_obj_equal(mrb, range, obj)) return mrb_true_value();
|
191
189
|
if (!mrb_obj_is_instance_of(mrb, obj, mrb_obj_class(mrb, range))) { /* same class? */
|
192
190
|
return mrb_false_value();
|
@@ -211,13 +209,11 @@ range_eq(mrb_state *mrb, mrb_value range)
|
|
211
209
|
static mrb_value
|
212
210
|
range_include(mrb_state *mrb, mrb_value range)
|
213
211
|
{
|
214
|
-
mrb_value val;
|
212
|
+
mrb_value val = mrb_get_arg1(mrb);
|
215
213
|
struct RRange *r = mrb_range_ptr(mrb, range);
|
216
214
|
mrb_value beg, end;
|
217
215
|
mrb_bool include_p;
|
218
216
|
|
219
|
-
mrb_get_args(mrb, "o", &val);
|
220
|
-
|
221
217
|
beg = RANGE_BEG(r);
|
222
218
|
end = RANGE_END(r);
|
223
219
|
include_p = r_le(mrb, beg, val) && /* beg <= val */
|
@@ -289,11 +285,9 @@ range_inspect(mrb_state *mrb, mrb_value range)
|
|
289
285
|
static mrb_value
|
290
286
|
range_eql(mrb_state *mrb, mrb_value range)
|
291
287
|
{
|
292
|
-
mrb_value obj;
|
288
|
+
mrb_value obj = mrb_get_arg1(mrb);
|
293
289
|
struct RRange *r, *o;
|
294
290
|
|
295
|
-
mrb_get_args(mrb, "o", &obj);
|
296
|
-
|
297
291
|
if (mrb_obj_equal(mrb, range, obj)) return mrb_true_value();
|
298
292
|
if (!mrb_obj_is_kind_of(mrb, obj, mrb->range_class)) return mrb_false_value();
|
299
293
|
if (!mrb_range_p(obj)) return mrb_false_value();
|
@@ -312,11 +306,9 @@ range_eql(mrb_state *mrb, mrb_value range)
|
|
312
306
|
static mrb_value
|
313
307
|
range_initialize_copy(mrb_state *mrb, mrb_value copy)
|
314
308
|
{
|
315
|
-
mrb_value src;
|
309
|
+
mrb_value src = mrb_get_arg1(mrb);
|
316
310
|
struct RRange *r;
|
317
311
|
|
318
|
-
mrb_get_args(mrb, "o", &src);
|
319
|
-
|
320
312
|
if (mrb_obj_equal(mrb, copy, src)) return copy;
|
321
313
|
if (!mrb_obj_is_instance_of(mrb, src, mrb_obj_class(mrb, copy))) {
|
322
314
|
mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class");
|
@@ -19,11 +19,25 @@ void mrb_init_mrbgems(mrb_state*);
|
|
19
19
|
void mrb_gc_init(mrb_state*, mrb_gc *gc);
|
20
20
|
void mrb_gc_destroy(mrb_state*, mrb_gc *gc);
|
21
21
|
|
22
|
+
int mrb_core_init_protect(mrb_state *mrb, void (*body)(mrb_state *, void *), void *opaque);
|
23
|
+
|
24
|
+
static void
|
25
|
+
init_gc_and_core(mrb_state *mrb, void *opaque)
|
26
|
+
{
|
27
|
+
static const struct mrb_context mrb_context_zero = { 0 };
|
28
|
+
|
29
|
+
mrb_gc_init(mrb, &mrb->gc);
|
30
|
+
mrb->c = (struct mrb_context*)mrb_malloc(mrb, sizeof(struct mrb_context));
|
31
|
+
*mrb->c = mrb_context_zero;
|
32
|
+
mrb->root_c = mrb->c;
|
33
|
+
|
34
|
+
mrb_init_core(mrb);
|
35
|
+
}
|
36
|
+
|
22
37
|
MRB_API mrb_state*
|
23
38
|
mrb_open_core(mrb_allocf f, void *ud)
|
24
39
|
{
|
25
40
|
static const mrb_state mrb_state_zero = { 0 };
|
26
|
-
static const struct mrb_context mrb_context_zero = { 0 };
|
27
41
|
mrb_state *mrb;
|
28
42
|
|
29
43
|
if (f == NULL) f = mrb_default_allocf;
|
@@ -35,12 +49,10 @@ mrb_open_core(mrb_allocf f, void *ud)
|
|
35
49
|
mrb->allocf = f;
|
36
50
|
mrb->atexit_stack_len = 0;
|
37
51
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
mrb_init_core(mrb);
|
52
|
+
if (mrb_core_init_protect(mrb, init_gc_and_core, NULL)) {
|
53
|
+
mrb_close(mrb);
|
54
|
+
return NULL;
|
55
|
+
}
|
44
56
|
|
45
57
|
return mrb;
|
46
58
|
}
|
@@ -65,6 +77,12 @@ mrb_open(void)
|
|
65
77
|
return mrb;
|
66
78
|
}
|
67
79
|
|
80
|
+
static void
|
81
|
+
init_mrbgems(mrb_state *mrb, void *opaque)
|
82
|
+
{
|
83
|
+
mrb_init_mrbgems(mrb);
|
84
|
+
}
|
85
|
+
|
68
86
|
MRB_API mrb_state*
|
69
87
|
mrb_open_allocf(mrb_allocf f, void *ud)
|
70
88
|
{
|
@@ -75,7 +93,10 @@ mrb_open_allocf(mrb_allocf f, void *ud)
|
|
75
93
|
}
|
76
94
|
|
77
95
|
#ifndef DISABLE_GEMS
|
78
|
-
|
96
|
+
if (mrb_core_init_protect(mrb, init_mrbgems, NULL)) {
|
97
|
+
mrb_close(mrb);
|
98
|
+
return NULL;
|
99
|
+
}
|
79
100
|
mrb_gc_arena_restore(mrb, 0);
|
80
101
|
#endif
|
81
102
|
return mrb;
|
@@ -131,9 +152,11 @@ mrb_irep_free(mrb_state *mrb, mrb_irep *irep)
|
|
131
152
|
}
|
132
153
|
mrb_free(mrb, irep->pool);
|
133
154
|
mrb_free(mrb, irep->syms);
|
134
|
-
|
135
|
-
|
136
|
-
|
155
|
+
if (irep->reps) {
|
156
|
+
for (i=0; i<irep->rlen; i++) {
|
157
|
+
if (irep->reps[i])
|
158
|
+
mrb_irep_decref(mrb, irep->reps[i]);
|
159
|
+
}
|
137
160
|
}
|
138
161
|
mrb_free(mrb, irep->reps);
|
139
162
|
mrb_free(mrb, irep->lv);
|
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
#ifndef MRB_WITHOUT_FLOAT
|
12
12
|
#include <float.h>
|
13
|
+
#include <math.h>
|
13
14
|
#endif
|
14
15
|
#include <limits.h>
|
15
16
|
#include <stddef.h>
|
@@ -300,8 +301,8 @@ static const char utf8len_codepage[256] =
|
|
300
301
|
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,
|
301
302
|
};
|
302
303
|
|
303
|
-
|
304
|
-
|
304
|
+
mrb_int
|
305
|
+
mrb_utf8len(const char* p, const char* e)
|
305
306
|
{
|
306
307
|
mrb_int len;
|
307
308
|
mrb_int i;
|
@@ -317,14 +318,14 @@ utf8len(const char* p, const char* e)
|
|
317
318
|
}
|
318
319
|
|
319
320
|
mrb_int
|
320
|
-
|
321
|
+
mrb_utf8_strlen(const char *str, mrb_int byte_len)
|
321
322
|
{
|
322
323
|
mrb_int total = 0;
|
323
324
|
const char *p = str;
|
324
325
|
const char *e = p + byte_len;
|
325
326
|
|
326
327
|
while (p < e) {
|
327
|
-
p +=
|
328
|
+
p += mrb_utf8len(p, e);
|
328
329
|
total++;
|
329
330
|
}
|
330
331
|
return total;
|
@@ -340,7 +341,7 @@ utf8_strlen(mrb_value str)
|
|
340
341
|
return byte_len;
|
341
342
|
}
|
342
343
|
else {
|
343
|
-
mrb_int utf8_len =
|
344
|
+
mrb_int utf8_len = mrb_utf8_strlen(RSTR_PTR(s), byte_len);
|
344
345
|
if (byte_len == utf8_len) RSTR_SET_ASCII_FLAG(s);
|
345
346
|
return utf8_len;
|
346
347
|
}
|
@@ -361,7 +362,7 @@ chars2bytes(mrb_value s, mrb_int off, mrb_int idx)
|
|
361
362
|
const char *e = RSTRING_END(s);
|
362
363
|
|
363
364
|
for (b=i=0; p<e && i<idx; i++) {
|
364
|
-
n =
|
365
|
+
n = mrb_utf8len(p, e);
|
365
366
|
b += n;
|
366
367
|
p += n;
|
367
368
|
}
|
@@ -378,7 +379,7 @@ bytes2chars(char *p, mrb_int len, mrb_int bi)
|
|
378
379
|
mrb_int i;
|
379
380
|
|
380
381
|
for (i = 0; p < pivot; i ++) {
|
381
|
-
p +=
|
382
|
+
p += mrb_utf8len(p, e);
|
382
383
|
}
|
383
384
|
if (p != pivot) return -1;
|
384
385
|
return i;
|
@@ -399,7 +400,7 @@ char_adjust(const char *beg, const char *end, const char *ptr)
|
|
399
400
|
while (p > beg) {
|
400
401
|
p --;
|
401
402
|
if ((*p & 0xc0) != 0x80) {
|
402
|
-
int clen =
|
403
|
+
int clen = mrb_utf8len(p, end);
|
403
404
|
if (clen > ptr - p) return p;
|
404
405
|
break;
|
405
406
|
}
|
@@ -462,10 +463,10 @@ str_index_str_by_char_search(mrb_state *mrb, const char *p, const char *pend, co
|
|
462
463
|
}
|
463
464
|
|
464
465
|
pivot = p + qstable[(unsigned char)p[slen - 1]];
|
465
|
-
if (pivot
|
466
|
+
if (pivot >= pend || pivot < p /* overflowed */) { return -1; }
|
466
467
|
|
467
468
|
do {
|
468
|
-
p +=
|
469
|
+
p += mrb_utf8len(p, pend);
|
469
470
|
off ++;
|
470
471
|
} while (p < pivot);
|
471
472
|
}
|
@@ -484,7 +485,7 @@ str_index_str_by_char(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos)
|
|
484
485
|
|
485
486
|
for (; pos > 0; pos --) {
|
486
487
|
if (pend - p < 1) { return -1; }
|
487
|
-
p +=
|
488
|
+
p += mrb_utf8len(p, pend);
|
488
489
|
}
|
489
490
|
|
490
491
|
if (slen < 1) { return off; }
|
@@ -503,25 +504,45 @@ str_index_str_by_char(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos)
|
|
503
504
|
#define str_index_str_by_char(mrb, str, sub, pos) str_index_str(mrb, str, sub, pos)
|
504
505
|
#endif
|
505
506
|
|
507
|
+
#ifndef MRB_QS_SHORT_STRING_LENGTH
|
508
|
+
#define MRB_QS_SHORT_STRING_LENGTH 2048
|
509
|
+
#endif
|
510
|
+
|
506
511
|
static inline mrb_int
|
507
512
|
mrb_memsearch_qs(const unsigned char *xs, mrb_int m, const unsigned char *ys, mrb_int n)
|
508
513
|
{
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
ptrdiff_t qstable[256];
|
514
|
+
if (n + m < MRB_QS_SHORT_STRING_LENGTH) {
|
515
|
+
const unsigned char *y = ys;
|
516
|
+
const unsigned char *ye = ys+n-m+1;
|
513
517
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
518
|
+
for (;;) {
|
519
|
+
y = (const unsigned char*)memchr(y, xs[0], (size_t)(ye-y));
|
520
|
+
if (y == NULL) return -1;
|
521
|
+
if (memcmp(xs, y, m) == 0) {
|
522
|
+
return (mrb_int)(y - ys);
|
523
|
+
}
|
524
|
+
y++;
|
525
|
+
}
|
526
|
+
return -1;
|
527
|
+
}
|
528
|
+
else {
|
529
|
+
const unsigned char *x = xs, *xe = xs + m;
|
530
|
+
const unsigned char *y = ys;
|
531
|
+
int i;
|
532
|
+
ptrdiff_t qstable[256];
|
533
|
+
|
534
|
+
/* Preprocessing */
|
535
|
+
for (i = 0; i < 256; ++i)
|
536
|
+
qstable[i] = m + 1;
|
537
|
+
for (; x < xe; ++x)
|
538
|
+
qstable[*x] = xe - x;
|
539
|
+
/* Searching */
|
540
|
+
for (; y + m <= ys + n; y += *(qstable + y[m])) {
|
541
|
+
if (*xs == *y && memcmp(xs, y, m) == 0)
|
542
|
+
return (mrb_int)(y - ys);
|
543
|
+
}
|
544
|
+
return -1;
|
523
545
|
}
|
524
|
-
return -1;
|
525
546
|
}
|
526
547
|
|
527
548
|
static mrb_int
|
@@ -1040,10 +1061,9 @@ mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2)
|
|
1040
1061
|
static mrb_value
|
1041
1062
|
mrb_str_cmp_m(mrb_state *mrb, mrb_value str1)
|
1042
1063
|
{
|
1043
|
-
mrb_value str2;
|
1064
|
+
mrb_value str2 = mrb_get_arg1(mrb);
|
1044
1065
|
mrb_int result;
|
1045
1066
|
|
1046
|
-
mrb_get_args(mrb, "o", &str2);
|
1047
1067
|
if (!mrb_string_p(str2)) {
|
1048
1068
|
return mrb_nil_value();
|
1049
1069
|
}
|
@@ -1085,9 +1105,7 @@ mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2)
|
|
1085
1105
|
static mrb_value
|
1086
1106
|
mrb_str_equal_m(mrb_state *mrb, mrb_value str1)
|
1087
1107
|
{
|
1088
|
-
mrb_value str2;
|
1089
|
-
|
1090
|
-
mrb_get_args(mrb, "o", &str2);
|
1108
|
+
mrb_value str2 = mrb_get_arg1(mrb);
|
1091
1109
|
|
1092
1110
|
return mrb_bool_value(mrb_str_equal(mrb, str1, str2));
|
1093
1111
|
}
|
@@ -1341,7 +1359,7 @@ str_escape(mrb_state *mrb, mrb_value str, mrb_bool inspect)
|
|
1341
1359
|
unsigned char c, cc;
|
1342
1360
|
#ifdef MRB_UTF8_STRING
|
1343
1361
|
if (inspect) {
|
1344
|
-
mrb_int clen =
|
1362
|
+
mrb_int clen = mrb_utf8len(p, pend);
|
1345
1363
|
if (clen > 1) {
|
1346
1364
|
mrb_int i;
|
1347
1365
|
|
@@ -1644,7 +1662,7 @@ mrb_str_chop_bang(mrb_state *mrb, mrb_value str)
|
|
1644
1662
|
const char* t = RSTR_PTR(s), *p = t;
|
1645
1663
|
const char* e = p + RSTR_LEN(s);
|
1646
1664
|
while (p<e) {
|
1647
|
-
mrb_int clen =
|
1665
|
+
mrb_int clen = mrb_utf8len(p, e);
|
1648
1666
|
if (p + clen>=e) break;
|
1649
1667
|
p += clen;
|
1650
1668
|
}
|
@@ -1770,10 +1788,9 @@ mrb_str_empty_p(mrb_state *mrb, mrb_value self)
|
|
1770
1788
|
static mrb_value
|
1771
1789
|
mrb_str_eql(mrb_state *mrb, mrb_value self)
|
1772
1790
|
{
|
1773
|
-
mrb_value str2;
|
1791
|
+
mrb_value str2 = mrb_get_arg1(mrb);
|
1774
1792
|
mrb_bool eql_p;
|
1775
1793
|
|
1776
|
-
mrb_get_args(mrb, "o", &str2);
|
1777
1794
|
eql_p = (mrb_string_p(str2)) && str_eql(mrb, self, str2);
|
1778
1795
|
|
1779
1796
|
return mrb_bool_value(eql_p);
|
@@ -2016,7 +2033,7 @@ mrb_str_reverse_bang(mrb_state *mrb, mrb_value str)
|
|
2016
2033
|
p = RSTR_PTR(s);
|
2017
2034
|
e = p + RSTR_LEN(s);
|
2018
2035
|
while (p<e) {
|
2019
|
-
mrb_int clen =
|
2036
|
+
mrb_int clen = mrb_utf8len(p, e);
|
2020
2037
|
str_reverse(p, p + clen - 1);
|
2021
2038
|
p += clen;
|
2022
2039
|
}
|
@@ -2491,16 +2508,18 @@ mrb_str_to_i(mrb_state *mrb, mrb_value self)
|
|
2491
2508
|
double
|
2492
2509
|
mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
|
2493
2510
|
{
|
2494
|
-
char buf[DBL_DIG * 4 +
|
2495
|
-
const char *p = s;
|
2511
|
+
char buf[DBL_DIG * 4 + 20];
|
2512
|
+
const char *p = s, *p2;
|
2496
2513
|
const char *pend = p + len;
|
2497
2514
|
char *end;
|
2498
2515
|
char *n;
|
2499
2516
|
char prev = 0;
|
2500
2517
|
double d;
|
2518
|
+
mrb_bool dot = FALSE;
|
2501
2519
|
|
2502
2520
|
if (!p) return 0.0;
|
2503
|
-
while (ISSPACE(*p)) p++;
|
2521
|
+
while (p<pend && ISSPACE(*p)) p++;
|
2522
|
+
p2 = p;
|
2504
2523
|
|
2505
2524
|
if (pend - p > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
|
2506
2525
|
mrb_value x;
|
@@ -2515,21 +2534,27 @@ mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
|
|
2515
2534
|
}
|
2516
2535
|
while (p < pend) {
|
2517
2536
|
if (!*p) {
|
2518
|
-
if (badcheck
|
2537
|
+
if (badcheck) {
|
2519
2538
|
mrb_raise(mrb, E_ARGUMENT_ERROR, "string for Float contains null byte");
|
2520
2539
|
/* not reached */
|
2521
2540
|
}
|
2522
2541
|
pend = p;
|
2523
|
-
p =
|
2542
|
+
p = p2;
|
2543
|
+
goto nocopy;
|
2544
|
+
}
|
2545
|
+
if (!badcheck && *p == ' ') {
|
2546
|
+
pend = p;
|
2547
|
+
p = p2;
|
2524
2548
|
goto nocopy;
|
2525
2549
|
}
|
2526
2550
|
if (*p == '_') break;
|
2527
2551
|
p++;
|
2528
2552
|
}
|
2529
|
-
p =
|
2553
|
+
p = p2;
|
2530
2554
|
n = buf;
|
2531
2555
|
while (p < pend) {
|
2532
2556
|
char c = *p++;
|
2557
|
+
if (c == '.') dot = TRUE;
|
2533
2558
|
if (c == '_') {
|
2534
2559
|
/* remove an underscore between digits */
|
2535
2560
|
if (n == buf || !ISDIGIT(prev) || p == pend) {
|
@@ -2539,6 +2564,11 @@ mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
|
|
2539
2564
|
}
|
2540
2565
|
else if (badcheck && prev == '_' && !ISDIGIT(c)) goto bad;
|
2541
2566
|
else {
|
2567
|
+
const char *bend = buf+sizeof(buf)-1;
|
2568
|
+
if (n==bend) { /* buffer overflow */
|
2569
|
+
if (dot) break; /* cut off remaining fractions */
|
2570
|
+
return INFINITY;
|
2571
|
+
}
|
2542
2572
|
*n++ = c;
|
2543
2573
|
}
|
2544
2574
|
prev = c;
|
@@ -2725,7 +2755,7 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
|
|
2725
2755
|
MRB_API mrb_value
|
2726
2756
|
mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
|
2727
2757
|
{
|
2728
|
-
return mrb_str_cat(mrb, str, ptr, strlen(ptr));
|
2758
|
+
return mrb_str_cat(mrb, str, ptr, ptr ? strlen(ptr) : 0);
|
2729
2759
|
}
|
2730
2760
|
|
2731
2761
|
MRB_API mrb_value
|
@@ -2855,25 +2885,32 @@ mrb_str_setbyte(mrb_state *mrb, mrb_value str)
|
|
2855
2885
|
static mrb_value
|
2856
2886
|
mrb_str_byteslice(mrb_state *mrb, mrb_value str)
|
2857
2887
|
{
|
2858
|
-
mrb_value a1
|
2888
|
+
mrb_value a1;
|
2859
2889
|
mrb_int str_len = RSTRING_LEN(str), beg, len;
|
2860
2890
|
mrb_bool empty = TRUE;
|
2861
2891
|
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2892
|
+
len = mrb_get_argc(mrb);
|
2893
|
+
switch (len) {
|
2894
|
+
case 2:
|
2895
|
+
mrb_get_args(mrb, "ii", &beg, &len);
|
2896
|
+
break;
|
2897
|
+
case 1:
|
2898
|
+
a1 = mrb_get_arg1(mrb);
|
2899
|
+
if (mrb_range_p(a1)) {
|
2900
|
+
if (mrb_range_beg_len(mrb, a1, &beg, &len, str_len, TRUE) != MRB_RANGE_OK) {
|
2901
|
+
return mrb_nil_value();
|
2902
|
+
}
|
2869
2903
|
}
|
2904
|
+
else {
|
2905
|
+
beg = mrb_fixnum(mrb_to_int(mrb, a1));
|
2906
|
+
len = 1;
|
2907
|
+
empty = FALSE;
|
2908
|
+
}
|
2909
|
+
break;
|
2910
|
+
default:
|
2911
|
+
mrb_argnum_error(mrb, len, 1, 2);
|
2912
|
+
break;
|
2870
2913
|
}
|
2871
|
-
else {
|
2872
|
-
beg = mrb_fixnum(mrb_to_int(mrb, a1));
|
2873
|
-
len = 1;
|
2874
|
-
empty = FALSE;
|
2875
|
-
}
|
2876
|
-
|
2877
2914
|
if (mrb_str_beg_len(str_len, &beg, &len) && (empty || len != 0)) {
|
2878
2915
|
return mrb_str_byte_subseq(mrb, str, beg, len);
|
2879
2916
|
}
|