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
@@ -130,6 +130,10 @@ codedump(mrb_state *mrb, mrb_irep *irep)
|
|
130
130
|
printf("OP_LOADI\tR%d\t-%d\t", a, b);
|
131
131
|
print_lv_a(mrb, irep, a);
|
132
132
|
break;
|
133
|
+
CASE(OP_LOADI16, BS):
|
134
|
+
printf("OP_LOADI16\tR%d\t%d\t", a, (int)(int16_t)b);
|
135
|
+
print_lv_a(mrb, irep, a);
|
136
|
+
break;
|
133
137
|
CASE(OP_LOADI__1, B):
|
134
138
|
printf("OP_LOADI__1\tR%d\t\t", a);
|
135
139
|
print_lv_a(mrb, irep, a);
|
@@ -204,11 +204,14 @@ mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d)
|
|
204
204
|
|
205
205
|
if (!d) { return; }
|
206
206
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
207
|
+
if (d->files) {
|
208
|
+
for (i = 0; i < d->flen; ++i) {
|
209
|
+
if (d->files[i]) {
|
210
|
+
mrb_free(mrb, d->files[i]->lines.ptr);
|
211
|
+
mrb_free(mrb, d->files[i]);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
mrb_free(mrb, d->files);
|
211
215
|
}
|
212
|
-
mrb_free(mrb, d->files);
|
213
216
|
mrb_free(mrb, d);
|
214
217
|
}
|
@@ -13,9 +13,6 @@
|
|
13
13
|
#include <mruby/numeric.h>
|
14
14
|
#include <mruby/debug.h>
|
15
15
|
|
16
|
-
#define FLAG_BYTEORDER_NATIVE 2
|
17
|
-
#define FLAG_BYTEORDER_NONATIVE 0
|
18
|
-
|
19
16
|
#ifndef MRB_WITHOUT_FLOAT
|
20
17
|
#ifdef MRB_USE_FLOAT
|
21
18
|
#define MRB_FLOAT_FMT "%.9g"
|
@@ -709,22 +706,7 @@ write_rite_binary_header(mrb_state *mrb, size_t binary_size, uint8_t *bin, uint8
|
|
709
706
|
uint16_t crc;
|
710
707
|
uint32_t offset;
|
711
708
|
|
712
|
-
|
713
|
-
endian_big:
|
714
|
-
case DUMP_ENDIAN_BIG:
|
715
|
-
memcpy(header->binary_ident, RITE_BINARY_IDENT, sizeof(header->binary_ident));
|
716
|
-
break;
|
717
|
-
endian_little:
|
718
|
-
case DUMP_ENDIAN_LIL:
|
719
|
-
memcpy(header->binary_ident, RITE_BINARY_IDENT_LIL, sizeof(header->binary_ident));
|
720
|
-
break;
|
721
|
-
|
722
|
-
case DUMP_ENDIAN_NAT:
|
723
|
-
if (bigendian_p()) goto endian_big;
|
724
|
-
goto endian_little;
|
725
|
-
break;
|
726
|
-
}
|
727
|
-
|
709
|
+
memcpy(header->binary_ident, RITE_BINARY_IDENT, sizeof(header->binary_ident));
|
728
710
|
memcpy(header->binary_version, RITE_BINARY_FORMAT_VER, sizeof(header->binary_version));
|
729
711
|
memcpy(header->compiler_name, RITE_COMPILER_NAME, sizeof(header->compiler_name));
|
730
712
|
memcpy(header->compiler_version, RITE_COMPILER_VERSION, sizeof(header->compiler_version));
|
@@ -764,21 +746,6 @@ lv_defined_p(mrb_irep *irep)
|
|
764
746
|
return FALSE;
|
765
747
|
}
|
766
748
|
|
767
|
-
static uint8_t
|
768
|
-
dump_flags(uint8_t flags, uint8_t native)
|
769
|
-
{
|
770
|
-
if (native == FLAG_BYTEORDER_NATIVE) {
|
771
|
-
if ((flags & DUMP_ENDIAN_NAT) == 0) {
|
772
|
-
return (flags & DUMP_DEBUG_INFO) | DUMP_ENDIAN_NAT;
|
773
|
-
}
|
774
|
-
return flags;
|
775
|
-
}
|
776
|
-
if ((flags & DUMP_ENDIAN_NAT) == 0) {
|
777
|
-
return (flags & DUMP_DEBUG_INFO) | DUMP_ENDIAN_BIG;
|
778
|
-
}
|
779
|
-
return flags;
|
780
|
-
}
|
781
|
-
|
782
749
|
static int
|
783
750
|
dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
|
784
751
|
{
|
@@ -870,7 +837,7 @@ error_exit:
|
|
870
837
|
int
|
871
838
|
mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
|
872
839
|
{
|
873
|
-
return dump_irep(mrb, irep,
|
840
|
+
return dump_irep(mrb, irep, flags, bin, bin_size);
|
874
841
|
}
|
875
842
|
|
876
843
|
#ifndef MRB_DISABLE_STDIO
|
@@ -886,7 +853,7 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
|
|
886
853
|
return MRB_DUMP_INVALID_ARGUMENT;
|
887
854
|
}
|
888
855
|
|
889
|
-
result = dump_irep(mrb, irep,
|
856
|
+
result = dump_irep(mrb, irep, flags, &bin, &bin_size);
|
890
857
|
if (result == MRB_DUMP_OK) {
|
891
858
|
if (fwrite(bin, sizeof(bin[0]), bin_size, fp) != bin_size) {
|
892
859
|
result = MRB_DUMP_WRITE_FAULT;
|
@@ -897,20 +864,6 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
|
|
897
864
|
return result;
|
898
865
|
}
|
899
866
|
|
900
|
-
static mrb_bool
|
901
|
-
dump_bigendian_p(uint8_t flags)
|
902
|
-
{
|
903
|
-
switch (flags & DUMP_ENDIAN_NAT) {
|
904
|
-
case DUMP_ENDIAN_BIG:
|
905
|
-
return TRUE;
|
906
|
-
case DUMP_ENDIAN_LIL:
|
907
|
-
return FALSE;
|
908
|
-
default:
|
909
|
-
case DUMP_ENDIAN_NAT:
|
910
|
-
return bigendian_p();
|
911
|
-
}
|
912
|
-
}
|
913
|
-
|
914
867
|
int
|
915
868
|
mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname)
|
916
869
|
{
|
@@ -921,23 +874,8 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
|
|
921
874
|
if (fp == NULL || initname == NULL || initname[0] == '\0') {
|
922
875
|
return MRB_DUMP_INVALID_ARGUMENT;
|
923
876
|
}
|
924
|
-
flags = dump_flags(flags, FLAG_BYTEORDER_NATIVE);
|
925
877
|
result = dump_irep(mrb, irep, flags, &bin, &bin_size);
|
926
878
|
if (result == MRB_DUMP_OK) {
|
927
|
-
if (!dump_bigendian_p(flags)) {
|
928
|
-
if (fprintf(fp, "/* dumped in little endian order.\n"
|
929
|
-
" use `mrbc -E` option for big endian CPU. */\n") < 0) {
|
930
|
-
mrb_free(mrb, bin);
|
931
|
-
return MRB_DUMP_WRITE_FAULT;
|
932
|
-
}
|
933
|
-
}
|
934
|
-
else {
|
935
|
-
if (fprintf(fp, "/* dumped in big endian order.\n"
|
936
|
-
" use `mrbc -e` option for better performance on little endian CPU. */\n") < 0) {
|
937
|
-
mrb_free(mrb, bin);
|
938
|
-
return MRB_DUMP_WRITE_FAULT;
|
939
|
-
}
|
940
|
-
}
|
941
879
|
if (fprintf(fp, "#include <stdint.h>\n") < 0) { /* for uint8_t under at least Darwin */
|
942
880
|
mrb_free(mrb, bin);
|
943
881
|
return MRB_DUMP_WRITE_FAULT;
|
@@ -160,9 +160,8 @@ set_backtrace(mrb_state *mrb, mrb_value exc, mrb_value backtrace)
|
|
160
160
|
static mrb_value
|
161
161
|
exc_set_backtrace(mrb_state *mrb, mrb_value exc)
|
162
162
|
{
|
163
|
-
mrb_value backtrace;
|
163
|
+
mrb_value backtrace = mrb_get_arg1(mrb);
|
164
164
|
|
165
|
-
mrb_get_args(mrb, "o", &backtrace);
|
166
165
|
set_backtrace(mrb, exc, backtrace);
|
167
166
|
return backtrace;
|
168
167
|
}
|
@@ -185,6 +184,16 @@ mrb_exc_set(mrb_state *mrb, mrb_value exc)
|
|
185
184
|
}
|
186
185
|
}
|
187
186
|
|
187
|
+
static mrb_noreturn void
|
188
|
+
exc_throw(mrb_state *mrb, mrb_value exc)
|
189
|
+
{
|
190
|
+
if (!mrb->jmp) {
|
191
|
+
mrb_p(mrb, exc);
|
192
|
+
abort();
|
193
|
+
}
|
194
|
+
MRB_THROW(mrb->jmp);
|
195
|
+
}
|
196
|
+
|
188
197
|
MRB_API mrb_noreturn void
|
189
198
|
mrb_exc_raise(mrb_state *mrb, mrb_value exc)
|
190
199
|
{
|
@@ -197,11 +206,7 @@ mrb_exc_raise(mrb_state *mrb, mrb_value exc)
|
|
197
206
|
}
|
198
207
|
mrb_exc_set(mrb, exc);
|
199
208
|
}
|
200
|
-
|
201
|
-
mrb_p(mrb, exc);
|
202
|
-
abort();
|
203
|
-
}
|
204
|
-
MRB_THROW(mrb->jmp);
|
209
|
+
exc_throw(mrb, exc);
|
205
210
|
}
|
206
211
|
|
207
212
|
MRB_API mrb_noreturn void
|
@@ -550,6 +555,52 @@ mrb_argnum_error(mrb_state *mrb, mrb_int argc, int min, int max)
|
|
550
555
|
#undef FMT
|
551
556
|
}
|
552
557
|
|
558
|
+
void mrb_core_init_printabort(void);
|
559
|
+
|
560
|
+
int
|
561
|
+
mrb_core_init_protect(mrb_state *mrb, void (*body)(mrb_state *, void *), void *opaque)
|
562
|
+
{
|
563
|
+
struct mrb_jmpbuf *prev_jmp = mrb->jmp;
|
564
|
+
struct mrb_jmpbuf c_jmp;
|
565
|
+
int err = 1;
|
566
|
+
|
567
|
+
MRB_TRY(&c_jmp) {
|
568
|
+
mrb->jmp = &c_jmp;
|
569
|
+
body(mrb, opaque);
|
570
|
+
err = 0;
|
571
|
+
} MRB_CATCH(&c_jmp) {
|
572
|
+
if (mrb->exc) {
|
573
|
+
mrb_p(mrb, mrb_obj_value(mrb->exc));
|
574
|
+
mrb->exc = NULL;
|
575
|
+
}
|
576
|
+
else {
|
577
|
+
mrb_core_init_printabort();
|
578
|
+
}
|
579
|
+
} MRB_END_EXC(&c_jmp);
|
580
|
+
|
581
|
+
mrb->jmp = prev_jmp;
|
582
|
+
|
583
|
+
return err;
|
584
|
+
}
|
585
|
+
|
586
|
+
mrb_noreturn void
|
587
|
+
mrb_core_init_abort(mrb_state *mrb)
|
588
|
+
{
|
589
|
+
mrb->exc = NULL;
|
590
|
+
exc_throw(mrb, mrb_nil_value());
|
591
|
+
}
|
592
|
+
|
593
|
+
mrb_noreturn void
|
594
|
+
mrb_raise_nomemory(mrb_state *mrb)
|
595
|
+
{
|
596
|
+
if (mrb->nomem_err) {
|
597
|
+
mrb_exc_raise(mrb, mrb_obj_value(mrb->nomem_err));
|
598
|
+
}
|
599
|
+
else {
|
600
|
+
mrb_core_init_abort(mrb);
|
601
|
+
}
|
602
|
+
}
|
603
|
+
|
553
604
|
void
|
554
605
|
mrb_init_exception(mrb_state *mrb)
|
555
606
|
{
|
@@ -132,7 +132,6 @@ mrb_obj_id(mrb_value obj)
|
|
132
132
|
case MRB_TT_HASH:
|
133
133
|
case MRB_TT_RANGE:
|
134
134
|
case MRB_TT_EXCEPTION:
|
135
|
-
case MRB_TT_FILE:
|
136
135
|
case MRB_TT_DATA:
|
137
136
|
case MRB_TT_ISTRUCT:
|
138
137
|
default:
|
@@ -140,7 +139,13 @@ mrb_obj_id(mrb_value obj)
|
|
140
139
|
}
|
141
140
|
}
|
142
141
|
|
142
|
+
#if defined(MRB_NAN_BOXING) && defined(MRB_64BIT)
|
143
|
+
#define mrb_xxx_boxing_cptr_value mrb_nan_boxing_cptr_value
|
144
|
+
#endif
|
145
|
+
|
143
146
|
#ifdef MRB_WORD_BOXING
|
147
|
+
#define mrb_xxx_boxing_cptr_value mrb_word_boxing_cptr_value
|
148
|
+
|
144
149
|
#ifndef MRB_WITHOUT_FLOAT
|
145
150
|
MRB_API mrb_value
|
146
151
|
mrb_word_boxing_float_value(mrb_state *mrb, mrb_float f)
|
@@ -164,17 +169,20 @@ mrb_word_boxing_float_pool(mrb_state *mrb, mrb_float f)
|
|
164
169
|
return mrb_obj_value(nf);
|
165
170
|
}
|
166
171
|
#endif /* MRB_WITHOUT_FLOAT */
|
172
|
+
#endif /* MRB_WORD_BOXING */
|
167
173
|
|
174
|
+
#if defined(MRB_WORD_BOXING) || (defined(MRB_NAN_BOXING) && defined(MRB_64BIT))
|
168
175
|
MRB_API mrb_value
|
169
|
-
|
176
|
+
mrb_xxx_boxing_cptr_value(mrb_state *mrb, void *p)
|
170
177
|
{
|
171
178
|
mrb_value v;
|
179
|
+
struct RCptr *cptr = (struct RCptr*)mrb_obj_alloc(mrb, MRB_TT_CPTR, mrb->object_class);
|
172
180
|
|
173
|
-
v
|
174
|
-
|
181
|
+
SET_OBJ_VALUE(v, cptr);
|
182
|
+
cptr->p = p;
|
175
183
|
return v;
|
176
184
|
}
|
177
|
-
#endif
|
185
|
+
#endif
|
178
186
|
|
179
187
|
#if defined _MSC_VER && _MSC_VER < 1900
|
180
188
|
|
@@ -37,9 +37,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
37
37
|
#include <mruby.h>
|
38
38
|
#include <mruby/string.h>
|
39
39
|
|
40
|
+
struct fmt_args;
|
41
|
+
|
42
|
+
typedef void output_func(struct fmt_args *f, const char *s, size_t l);
|
43
|
+
|
40
44
|
struct fmt_args {
|
41
45
|
mrb_state *mrb;
|
42
|
-
|
46
|
+
output_func *output;
|
47
|
+
void *opaque;
|
48
|
+
};
|
49
|
+
|
50
|
+
struct mrb_cstr {
|
51
|
+
char *buf;
|
52
|
+
size_t len;
|
43
53
|
};
|
44
54
|
|
45
55
|
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
@@ -54,15 +64,44 @@ struct fmt_args {
|
|
54
64
|
#define PAD_POS (1U<<(' '-' '))
|
55
65
|
#define MARK_POS (1U<<('+'-' '))
|
56
66
|
|
67
|
+
#define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS)
|
68
|
+
|
69
|
+
static output_func strcat_value;
|
70
|
+
static output_func strcat_cstr;
|
71
|
+
|
72
|
+
static void
|
73
|
+
strcat_value(struct fmt_args *f, const char *s, size_t l)
|
74
|
+
{
|
75
|
+
mrb_value str = *(mrb_value*)f->opaque;
|
76
|
+
mrb_str_cat(f->mrb, str, s, l);
|
77
|
+
}
|
78
|
+
|
79
|
+
static void
|
80
|
+
strcat_cstr(struct fmt_args *f, const char *s, size_t l)
|
81
|
+
{
|
82
|
+
struct mrb_cstr *cstr = (struct mrb_cstr*)f->opaque;
|
83
|
+
|
84
|
+
if (l > cstr->len) {
|
85
|
+
mrb_state *mrb = f->mrb;
|
86
|
+
|
87
|
+
mrb_raise(mrb, E_ARGUMENT_ERROR, "string buffer too small");
|
88
|
+
}
|
89
|
+
|
90
|
+
memcpy(cstr->buf, s, l);
|
91
|
+
|
92
|
+
cstr->buf += l;
|
93
|
+
cstr->len -= l;
|
94
|
+
}
|
95
|
+
|
57
96
|
static void
|
58
97
|
out(struct fmt_args *f, const char *s, size_t l)
|
59
98
|
{
|
60
|
-
|
99
|
+
f->output(f, s, l);
|
61
100
|
}
|
62
101
|
|
63
102
|
#define PAD_SIZE 256
|
64
103
|
static void
|
65
|
-
pad(struct fmt_args *f, char c, ptrdiff_t w, ptrdiff_t l,
|
104
|
+
pad(struct fmt_args *f, char c, ptrdiff_t w, ptrdiff_t l, uint32_t fl)
|
66
105
|
{
|
67
106
|
char pad[PAD_SIZE];
|
68
107
|
if (fl & (LEFT_ADJ | ZERO_PAD) || l >= w) return;
|
@@ -92,7 +131,7 @@ typedef char compiler_defines_long_double_incorrectly[9-(int)sizeof(long double)
|
|
92
131
|
#endif
|
93
132
|
|
94
133
|
static int
|
95
|
-
fmt_fp(struct fmt_args *f, long double y, ptrdiff_t p,
|
134
|
+
fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl, int t)
|
96
135
|
{
|
97
136
|
uint32_t big[(LDBL_MANT_DIG+28)/29 + 1 // mantissa expansion
|
98
137
|
+ (LDBL_MAX_EXP+LDBL_MANT_DIG+28+8)/9]; // exponent expansion
|
@@ -117,11 +156,11 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t p, uint8_t fl, int t)
|
|
117
156
|
if (!isfinite(y)) {
|
118
157
|
const char *ss = (t&32)?"inf":"INF";
|
119
158
|
if (y!=y) ss=(t&32)?"nan":"NAN";
|
120
|
-
pad(f, ' ',
|
159
|
+
pad(f, ' ', w, 3+pl, fl&~ZERO_PAD);
|
121
160
|
out(f, prefix, pl);
|
122
161
|
out(f, ss, 3);
|
123
|
-
pad(f, ' ',
|
124
|
-
return
|
162
|
+
pad(f, ' ', w, 3+pl, fl^LEFT_ADJ);
|
163
|
+
return (int)MAX(w, 3+pl);
|
125
164
|
}
|
126
165
|
|
127
166
|
y = frexp((double)y, &e2) * 2;
|
@@ -169,14 +208,14 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t p, uint8_t fl, int t)
|
|
169
208
|
else
|
170
209
|
l = (s-buf) + (ebuf-estr);
|
171
210
|
|
172
|
-
pad(f, ' ',
|
211
|
+
pad(f, ' ', w, pl+l, fl);
|
173
212
|
out(f, prefix, pl);
|
174
|
-
pad(f, '0',
|
213
|
+
pad(f, '0', w, pl+l, fl^ZERO_PAD);
|
175
214
|
out(f, buf, s-buf);
|
176
215
|
pad(f, '0', l-(ebuf-estr)-(s-buf), 0, 0);
|
177
216
|
out(f, estr, ebuf-estr);
|
178
|
-
pad(f, ' ',
|
179
|
-
return (int)pl+
|
217
|
+
pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
|
218
|
+
return (int)MAX(w, pl+l);
|
180
219
|
}
|
181
220
|
if (p<0) p=6;
|
182
221
|
|
@@ -288,9 +327,9 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t p, uint8_t fl, int t)
|
|
288
327
|
l += ebuf-estr;
|
289
328
|
}
|
290
329
|
|
291
|
-
pad(f, ' ',
|
330
|
+
pad(f, ' ', w, pl+l, fl);
|
292
331
|
out(f, prefix, pl);
|
293
|
-
pad(f, '0',
|
332
|
+
pad(f, '0', w, pl+l, fl^ZERO_PAD);
|
294
333
|
|
295
334
|
if ((t|32)=='f') {
|
296
335
|
if (a>r) a=r;
|
@@ -325,21 +364,33 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t p, uint8_t fl, int t)
|
|
325
364
|
out(f, estr, ebuf-estr);
|
326
365
|
}
|
327
366
|
|
328
|
-
pad(f, ' ',
|
367
|
+
pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
|
329
368
|
|
330
|
-
return (int)pl+
|
369
|
+
return (int)MAX(w, pl+l);
|
331
370
|
}
|
332
371
|
|
333
372
|
static int
|
334
373
|
fmt_core(struct fmt_args *f, const char *fmt, mrb_float flo)
|
335
374
|
{
|
336
|
-
ptrdiff_t p;
|
375
|
+
ptrdiff_t w, p;
|
376
|
+
uint32_t fl;
|
337
377
|
|
338
378
|
if (*fmt != '%') {
|
339
379
|
return -1;
|
340
380
|
}
|
341
381
|
++fmt;
|
342
382
|
|
383
|
+
/* Read modifier flags */
|
384
|
+
for (fl=0; (unsigned)*fmt-' '<32 && (FLAGMASK&(1U<<(*fmt-' '))); fmt++)
|
385
|
+
fl |= 1U<<(*fmt-' ');
|
386
|
+
|
387
|
+
/* - and 0 flags are mutually exclusive */
|
388
|
+
if (fl & LEFT_ADJ) fl &= ~ZERO_PAD;
|
389
|
+
|
390
|
+
for (w = 0; ISDIGIT(*fmt); ++fmt) {
|
391
|
+
w = 10 * w + (*fmt - '0');
|
392
|
+
}
|
393
|
+
|
343
394
|
if (*fmt == '.') {
|
344
395
|
++fmt;
|
345
396
|
for (p = 0; ISDIGIT(*fmt); ++fmt) {
|
@@ -353,29 +404,49 @@ fmt_core(struct fmt_args *f, const char *fmt, mrb_float flo)
|
|
353
404
|
switch (*fmt) {
|
354
405
|
case 'e': case 'f': case 'g': case 'a':
|
355
406
|
case 'E': case 'F': case 'G': case 'A':
|
356
|
-
return fmt_fp(f, flo, p,
|
407
|
+
return fmt_fp(f, flo, w, p, fl, *fmt);
|
357
408
|
default:
|
358
409
|
return -1;
|
359
410
|
}
|
360
411
|
}
|
361
412
|
|
362
|
-
mrb_value
|
413
|
+
MRB_API mrb_value
|
363
414
|
mrb_float_to_str(mrb_state *mrb, mrb_value flo, const char *fmt)
|
364
415
|
{
|
365
416
|
struct fmt_args f;
|
417
|
+
mrb_value str = mrb_str_new_capa(mrb, 24);
|
366
418
|
|
367
419
|
f.mrb = mrb;
|
368
|
-
f.
|
420
|
+
f.output = strcat_value;
|
421
|
+
f.opaque = (void*)&str;
|
369
422
|
if (fmt_core(&f, fmt, mrb_float(flo)) < 0) {
|
370
423
|
mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format string");
|
371
424
|
}
|
372
|
-
return
|
425
|
+
return str;
|
426
|
+
}
|
427
|
+
|
428
|
+
MRB_API int
|
429
|
+
mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float fval)
|
430
|
+
{
|
431
|
+
struct fmt_args f;
|
432
|
+
struct mrb_cstr cstr;
|
433
|
+
|
434
|
+
cstr.buf = buf;
|
435
|
+
cstr.len = len - 1; /* reserve NUL terminator */
|
436
|
+
f.mrb = mrb;
|
437
|
+
f.output = strcat_cstr;
|
438
|
+
f.opaque = (void*)&cstr;
|
439
|
+
if (fmt_core(&f, fmt, fval) < 0) {
|
440
|
+
mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format string");
|
441
|
+
}
|
442
|
+
*cstr.buf = '\0';
|
443
|
+
return (int)(cstr.buf - buf);
|
373
444
|
}
|
374
445
|
#else /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */
|
375
446
|
#include <mruby.h>
|
376
447
|
#include <stdio.h>
|
377
448
|
|
378
|
-
mrb_value
|
449
|
+
MRB_API mrb_value
|
379
450
|
mrb_float_to_str(mrb_state *mrb, mrb_value flo, const char *fmt)
|
380
451
|
{
|
381
452
|
char buf[25];
|
@@ -383,5 +454,11 @@ mrb_float_to_str(mrb_state *mrb, mrb_value flo, const char *fmt)
|
|
383
454
|
snprintf(buf, sizeof(buf), fmt, mrb_float(flo));
|
384
455
|
return mrb_str_new_cstr(mrb, buf);
|
385
456
|
}
|
457
|
+
|
458
|
+
MRB_API int
|
459
|
+
mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float fval)
|
460
|
+
{
|
461
|
+
return snprintf(buf, len, fmt, fval);
|
462
|
+
}
|
386
463
|
#endif /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */
|
387
464
|
#endif
|