script_core 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +8 -6
- data/.ruby-version +1 -1
- data/Gemfile +2 -1
- data/bin/sandbox +1 -1
- data/ext/enterprise_script_service/Rakefile +1 -1
- data/ext/enterprise_script_service/flags.rb +5 -0
- data/ext/enterprise_script_service/libseccomp/CHANGELOG +15 -0
- data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
- data/ext/enterprise_script_service/libseccomp/Makefile.am +1 -1
- data/ext/enterprise_script_service/libseccomp/README.md +1 -1
- data/ext/enterprise_script_service/libseccomp/SECURITY.md +45 -0
- data/ext/enterprise_script_service/libseccomp/configure.ac +3 -3
- data/ext/enterprise_script_service/libseccomp/doc/admin/MAINTAINER_PROCESS.md +95 -0
- data/ext/enterprise_script_service/libseccomp/{RELEASE_PROCESS.md → doc/admin/RELEASE_PROCESS.md} +9 -1
- data/ext/enterprise_script_service/libseccomp/include/Makefile.am +1 -1
- data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +2292 -0
- data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +3 -1065
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +35 -3
- data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +35 -3
- data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +43 -11
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +33 -1
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +33 -1
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +34 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +43 -11
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +44 -12
- data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +46 -14
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +142 -18
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +47 -15
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +143 -17
- data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +33 -1
- data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +94 -12
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +142 -19
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +33 -1
- data/ext/enterprise_script_service/libseccomp/src/db.c +1 -0
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +10 -3
- data/ext/enterprise_script_service/libseccomp/src/python/Makefile.am +4 -4
- data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +2 -0
- data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.c +98 -0
- data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.py +61 -0
- data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.tests +18 -0
- data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
- data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -2
- data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -0
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
- data/ext/enterprise_script_service/mruby-mpdecimal/src/ext.c +1 -1
- data/ext/enterprise_script_service/mruby/.gitignore +2 -2
- data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +10 -3
- data/ext/enterprise_script_service/mruby/Doxyfile +2408 -0
- data/ext/enterprise_script_service/mruby/README.md +21 -8
- data/ext/enterprise_script_service/mruby/Rakefile +4 -13
- data/ext/enterprise_script_service/mruby/appveyor_config.rb +1 -1
- data/ext/enterprise_script_service/mruby/build_config.rb +3 -3
- data/ext/enterprise_script_service/mruby/doc/guides/compile.md +42 -42
- data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
- data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +45 -6
- data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +5 -0
- data/ext/enterprise_script_service/mruby/doc/limitations.md +88 -38
- data/ext/enterprise_script_service/mruby/doc/mruby_logo_red_icon.png +0 -0
- data/ext/enterprise_script_service/mruby/doc/opcode.md +94 -94
- data/ext/enterprise_script_service/mruby/include/mrbconf.h +74 -11
- data/ext/enterprise_script_service/mruby/include/mruby.h +242 -146
- data/ext/enterprise_script_service/mruby/include/mruby/array.h +7 -7
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +2 -9
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +11 -10
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +104 -69
- data/ext/enterprise_script_service/mruby/include/mruby/class.h +7 -5
- data/ext/enterprise_script_service/mruby/include/mruby/common.h +9 -7
- data/ext/enterprise_script_service/mruby/include/mruby/compile.h +6 -6
- data/ext/enterprise_script_service/mruby/include/mruby/data.h +5 -5
- data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/dump.h +3 -7
- data/ext/enterprise_script_service/mruby/include/mruby/error.h +34 -6
- data/ext/enterprise_script_service/mruby/include/mruby/gc.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/hash.h +4 -11
- data/ext/enterprise_script_service/mruby/include/mruby/irep.h +16 -4
- data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -4
- data/ext/enterprise_script_service/mruby/include/mruby/khash.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +41 -7
- data/ext/enterprise_script_service/mruby/include/mruby/object.h +8 -9
- data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/ops.h +6 -6
- data/ext/enterprise_script_service/mruby/include/mruby/proc.h +19 -13
- data/ext/enterprise_script_service/mruby/include/mruby/range.h +10 -4
- data/ext/enterprise_script_service/mruby/include/mruby/re.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/string.h +130 -107
- data/ext/enterprise_script_service/mruby/include/mruby/throw.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/value.h +137 -49
- data/ext/enterprise_script_service/mruby/include/mruby/variable.h +3 -5
- data/ext/enterprise_script_service/mruby/include/mruby/version.h +24 -10
- data/ext/enterprise_script_service/mruby/lib/mruby-core-ext.rb +2 -39
- data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +32 -15
- data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +63 -17
- data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +24 -10
- data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +11 -7
- data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +81 -0
- data/ext/enterprise_script_service/mruby/minirake +27 -11
- data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +3 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrbgem.rake +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +47 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +50 -29
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +4 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +28 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +75 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +134 -90
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +69 -46
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +0 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +51 -59
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +430 -241
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrbgem.rake +10 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +122 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +249 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +153 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/mrblib/chain.rb +19 -17
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/test/enum_chain.rb +41 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +30 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/test/enum.rb +8 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrbgem.rake +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +46 -14
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +51 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +10 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +47 -44
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-exit/src/mruby-exit.c +9 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +16 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/test/fiber.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +0 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +3 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +3 -7
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +0 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +24 -38
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/kernel.rb +16 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +19 -18
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +5 -16
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +54 -42
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +24 -20
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file_test.rb +4 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +41 -35
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +9 -36
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrbgem.rake +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +9 -27
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/test/kernel.rb +2 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +5 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +39 -24
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +48 -17
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/method.rb +0 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +134 -101
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +9 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +1 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +17 -37
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +0 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrblib/object.rb +15 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +35 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/test/nil.rb +4 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +1 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +28 -23
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/test/pack.rb +43 -49
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +3 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +6 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.rb +21 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +157 -124
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +72 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +38 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +26 -11
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +111 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrbgem.rake +5 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +117 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +209 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +308 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +10 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +22 -24
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrbgem.rake +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +8 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +116 -117
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/numeric.rb +29 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/range.rb +26 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/string.rb +32 -50
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +5 -7
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +43 -57
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/test/struct.rb +16 -11
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +152 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +4 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +200 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/include/mruby/time.h +2 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +199 -68
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/test/time.rb +81 -46
- data/ext/enterprise_script_service/mruby/mrblib/array.rb +14 -16
- data/ext/enterprise_script_service/mruby/mrblib/enum.rb +13 -9
- data/ext/enterprise_script_service/mruby/mrblib/hash.rb +5 -7
- data/ext/enterprise_script_service/mruby/mrblib/kernel.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +4 -4
- data/ext/enterprise_script_service/mruby/mrblib/range.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrblib/string.rb +55 -112
- data/ext/enterprise_script_service/mruby/mruby-source.gemspec +1 -1
- data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby.dict +105 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_fuzzer.options +5 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_proto_fuzzer.options +4 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_fuzzer.c +18 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +44 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.cpp +455 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +55 -0
- data/ext/enterprise_script_service/mruby/oss-fuzz/ruby.proto +201 -0
- data/ext/enterprise_script_service/mruby/src/array.c +95 -46
- data/ext/enterprise_script_service/mruby/src/backtrace.c +6 -8
- data/ext/enterprise_script_service/mruby/src/class.c +370 -278
- data/ext/enterprise_script_service/mruby/src/codedump.c +34 -34
- data/ext/enterprise_script_service/mruby/src/debug.c +2 -2
- data/ext/enterprise_script_service/mruby/src/dump.c +8 -6
- data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
- data/ext/enterprise_script_service/mruby/src/error.c +157 -55
- data/ext/enterprise_script_service/mruby/src/etc.c +13 -46
- data/ext/enterprise_script_service/mruby/src/fmt_fp.c +2 -2
- data/ext/enterprise_script_service/mruby/src/gc.c +30 -11
- data/ext/enterprise_script_service/mruby/src/hash.c +23 -14
- data/ext/enterprise_script_service/mruby/src/kernel.c +16 -54
- data/ext/enterprise_script_service/mruby/src/load.c +40 -76
- data/ext/enterprise_script_service/mruby/src/numeric.c +164 -94
- data/ext/enterprise_script_service/mruby/src/object.c +16 -39
- data/ext/enterprise_script_service/mruby/src/pool.c +0 -2
- data/ext/enterprise_script_service/mruby/src/proc.c +47 -48
- data/ext/enterprise_script_service/mruby/src/range.c +22 -35
- data/ext/enterprise_script_service/mruby/src/state.c +5 -94
- data/ext/enterprise_script_service/mruby/src/string.c +874 -710
- data/ext/enterprise_script_service/mruby/src/symbol.c +73 -48
- data/ext/enterprise_script_service/mruby/src/variable.c +58 -38
- data/ext/enterprise_script_service/mruby/src/vm.c +133 -304
- data/ext/enterprise_script_service/mruby/tasks/doc.rake +48 -0
- data/ext/enterprise_script_service/mruby/tasks/toolchains/clang.rake +3 -4
- data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +20 -19
- data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +0 -12
- data/ext/enterprise_script_service/mruby/test/assert.rb +186 -25
- data/ext/enterprise_script_service/mruby/test/t/array.rb +34 -6
- data/ext/enterprise_script_service/mruby/test/t/class.rb +26 -0
- data/ext/enterprise_script_service/mruby/test/t/enumerable.rb +2 -2
- data/ext/enterprise_script_service/mruby/test/t/float.rb +17 -17
- data/ext/enterprise_script_service/mruby/test/t/hash.rb +2 -0
- data/ext/enterprise_script_service/mruby/test/t/integer.rb +14 -6
- data/ext/enterprise_script_service/mruby/test/t/kernel.rb +38 -19
- data/ext/enterprise_script_service/mruby/test/t/module.rb +87 -14
- data/ext/enterprise_script_service/mruby/test/t/numeric.rb +65 -23
- data/ext/enterprise_script_service/mruby/test/t/range.rb +4 -4
- data/ext/enterprise_script_service/mruby/test/t/string.rb +211 -49
- data/ext/enterprise_script_service/mruby/test/t/syntax.rb +19 -2
- data/ext/enterprise_script_service/mruby/test/t/vformat.rb +92 -0
- data/ext/enterprise_script_service/mruby/travis_config.rb +2 -2
- data/ext/enterprise_script_service/mruby_config.rb +10 -0
- data/ext/enterprise_script_service/mruby_engine.cpp +2 -2
- data/ext/enterprise_script_service/mruby_engine.gembox +1 -0
- data/ext/enterprise_script_service/msgpack/CHANGELOG.md +14 -0
- data/ext/enterprise_script_service/msgpack/Files.cmake +4 -0
- data/ext/enterprise_script_service/msgpack/README.md +1 -1
- data/ext/enterprise_script_service/msgpack/appveyor.yml +1 -1
- data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple.hpp.erb +1 -1
- data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple_decl.hpp.erb +1 -1
- data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_zone.hpp.erb +3 -3
- data/ext/enterprise_script_service/msgpack/example/boost/asio_send_recv.cpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/cpp11/timespec.hpp +16 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/wstring.hpp +15 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/object.h +2 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/pack_template.h +17 -9
- data/ext/enterprise_script_service/msgpack/include/msgpack/sysdep.h +27 -16
- data/ext/enterprise_script_service/msgpack/include/msgpack/type.hpp +2 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/unpack_template.h +5 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +0 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/chrono.hpp +5 -5
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/timespec.hpp +140 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp +32 -32
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp +32 -32
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple.hpp +6 -6
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple_decl.hpp +10 -10
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/ext.hpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/fixint.hpp +5 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int.hpp +40 -13
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int_decl.hpp +3 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +121 -0
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp03_zone.hpp +3 -3
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp11_zone.hpp +3 -3
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object.hpp +6 -6
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object_fwd.hpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/pack.hpp +40 -5
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/unpack.hpp +11 -11
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/vrefbuffer.hpp +7 -7
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/zbuffer.hpp +5 -5
- data/ext/enterprise_script_service/msgpack/include/msgpack/v2/adaptor/int_decl.hpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v2/create_object_visitor.hpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v2/parse.hpp +13 -13
- data/ext/enterprise_script_service/msgpack/include/msgpack/v2/x3_parse.hpp +28 -26
- data/ext/enterprise_script_service/msgpack/include/msgpack/v3/adaptor/int_decl.hpp +1 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v3/parse.hpp +13 -13
- data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +6 -6
- data/ext/enterprise_script_service/msgpack/include/msgpack/zone.h +1 -1
- data/ext/enterprise_script_service/msgpack/src/objectc.c +83 -148
- data/ext/enterprise_script_service/msgpack/src/unpack.c +73 -47
- data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +1 -1
- data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +5 -0
- data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +5 -0
- data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +15 -9
- data/ext/enterprise_script_service/msgpack/test/buffer.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/carray.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/cases.cpp +7 -1
- data/ext/enterprise_script_service/msgpack/test/convert.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/fixint.cpp +7 -1
- data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +6 -1
- data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +5 -0
- data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +8 -2
- data/ext/enterprise_script_service/msgpack/test/json.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/limit.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +128 -6
- data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +7 -2
- data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +20 -3
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +159 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +5 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +8 -3
- data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +5 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +23 -18
- data/ext/enterprise_script_service/msgpack/test/object.cpp +77 -45
- data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +28 -10
- data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +25 -18
- data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/raw.cpp +17 -12
- data/ext/enterprise_script_service/msgpack/test/reference.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +6 -2
- data/ext/enterprise_script_service/msgpack/test/streaming.cpp +10 -3
- data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/user_class.cpp +5 -0
- data/ext/enterprise_script_service/msgpack/test/version.cpp +6 -0
- data/ext/enterprise_script_service/msgpack/test/visitor.cpp +7 -0
- data/ext/enterprise_script_service/msgpack/test/zone.cpp +6 -0
- data/lib/script_core/version.rb +1 -1
- data/lib/tasks/mruby/engine.gembox.example +1 -0
- data/lib/tasks/script_core.rake +21 -3
- data/spec/dummy/app/helpers/fields_helper.rb +2 -2
- data/spec/dummy/mruby/engine.gembox +1 -0
- data/spec/script_core_spec.rb +1 -1
- metadata +38 -22
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.gitignore +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.travis.yml +0 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/run_test.rb +0 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrblib/kernel.rb +0 -15
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/unbound_method.rb +0 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.gitignore +0 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.travis.yml +0 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb +0 -157
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/run_test.rb +0 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.c +0 -224
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.h +0 -80
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.h +0 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.gitignore +0 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis.yml +0 -29
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis_build_config.rb +0 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/Rakefile +0 -29
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/.travis.yml +0 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/run_test.rb +0 -28
@@ -48,14 +48,8 @@ def p(*args)
|
|
48
48
|
args.__svalue
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
else
|
56
|
-
def printf(*args)
|
57
|
-
__printstr__(sprintf(*args))
|
58
|
-
nil
|
59
|
-
end
|
51
|
+
def printf(*args)
|
52
|
+
__printstr__(sprintf(*args))
|
53
|
+
nil
|
60
54
|
end
|
61
55
|
end
|
@@ -38,7 +38,7 @@ mrb_proc_inspect(mrb_state *mrb, mrb_value self)
|
|
38
38
|
{
|
39
39
|
struct RProc *p = mrb_proc_ptr(self);
|
40
40
|
mrb_value str = mrb_str_new_lit(mrb, "#<Proc:");
|
41
|
-
|
41
|
+
mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, mrb_cptr(self)));
|
42
42
|
|
43
43
|
if (!MRB_PROC_CFUNC_P(p)) {
|
44
44
|
mrb_irep *irep = p->body.irep;
|
@@ -52,7 +52,7 @@ mrb_proc_inspect(mrb_state *mrb, mrb_value self)
|
|
52
52
|
|
53
53
|
line = mrb_debug_get_line(mrb, irep, 0);
|
54
54
|
if (line != -1) {
|
55
|
-
|
55
|
+
mrb_str_concat(mrb, str, mrb_fixnum_value(line));
|
56
56
|
}
|
57
57
|
else {
|
58
58
|
mrb_str_cat_lit(mrb, str, "-");
|
@@ -72,10 +72,7 @@ mrb_kernel_proc(mrb_state *mrb, mrb_value self)
|
|
72
72
|
{
|
73
73
|
mrb_value blk;
|
74
74
|
|
75
|
-
mrb_get_args(mrb, "
|
76
|
-
if (mrb_nil_p(blk)) {
|
77
|
-
mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Proc object without a block");
|
78
|
-
}
|
75
|
+
mrb_get_args(mrb, "&!", &blk);
|
79
76
|
|
80
77
|
return blk;
|
81
78
|
}
|
@@ -153,7 +150,7 @@ mrb_proc_parameters(mrb_state *mrb, mrb_value self)
|
|
153
150
|
mrb_ary_push(mrb, a, sname);
|
154
151
|
if (i < max && irep->lv[i].name) {
|
155
152
|
mrb_sym sym = irep->lv[i].name;
|
156
|
-
const char *name =
|
153
|
+
const char *name = mrb_sym_name(mrb, sym);
|
157
154
|
switch (name[0]) {
|
158
155
|
case '*': case '&':
|
159
156
|
break;
|
@@ -178,8 +175,8 @@ mrb_mruby_proc_ext_gem_init(mrb_state* mrb)
|
|
178
175
|
mrb_define_method(mrb, p, "inspect", mrb_proc_inspect, MRB_ARGS_NONE());
|
179
176
|
mrb_define_method(mrb, p, "parameters", mrb_proc_parameters, MRB_ARGS_NONE());
|
180
177
|
|
181
|
-
mrb_define_class_method(mrb, mrb->kernel_module, "proc", mrb_kernel_proc, MRB_ARGS_NONE());
|
182
|
-
mrb_define_method(mrb, mrb->kernel_module, "proc", mrb_kernel_proc, MRB_ARGS_NONE());
|
178
|
+
mrb_define_class_method(mrb, mrb->kernel_module, "proc", mrb_kernel_proc, MRB_ARGS_NONE()|MRB_ARGS_BLOCK());
|
179
|
+
mrb_define_method(mrb, mrb->kernel_module, "proc", mrb_kernel_proc, MRB_ARGS_NONE()|MRB_ARGS_BLOCK());
|
183
180
|
}
|
184
181
|
|
185
182
|
void
|
@@ -1,16 +1,32 @@
|
|
1
1
|
##
|
2
2
|
# Proc(Ext) Test
|
3
3
|
|
4
|
+
def enable_debug_info?
|
5
|
+
return @enable_debug_info unless @enable_debug_info == nil
|
6
|
+
begin
|
7
|
+
raise
|
8
|
+
rescue => e
|
9
|
+
@enable_debug_info = !e.backtrace.empty?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
4
13
|
assert('Proc#source_location') do
|
5
|
-
|
6
|
-
|
7
|
-
assert_equal
|
8
|
-
assert_equal
|
14
|
+
skip unless enable_debug_info?
|
15
|
+
file, line = Proc.new{}.source_location
|
16
|
+
assert_equal __FILE__, file
|
17
|
+
assert_equal __LINE__ - 2, line
|
9
18
|
end
|
10
19
|
|
11
20
|
assert('Proc#inspect') do
|
12
21
|
ins = Proc.new{}.inspect
|
13
|
-
|
22
|
+
if enable_debug_info?
|
23
|
+
metas = %w(\\ * ? [ ] { })
|
24
|
+
file = __FILE__.split("").map{|c| metas.include?(c) ? "\\#{c}" : c}.join
|
25
|
+
line = __LINE__ - 4
|
26
|
+
else
|
27
|
+
file = line = "-"
|
28
|
+
end
|
29
|
+
assert_match "#<Proc:0x*@#{file}:#{line}>", ins
|
14
30
|
end
|
15
31
|
|
16
32
|
assert('Proc#parameters') do
|
@@ -9,62 +9,105 @@
|
|
9
9
|
#include <mruby/class.h>
|
10
10
|
#include <mruby/data.h>
|
11
11
|
#include <mruby/array.h>
|
12
|
-
#include
|
12
|
+
#include <mruby/istruct.h>
|
13
|
+
#if INT32_MAX <= INTPTR_MAX
|
14
|
+
# define XORSHIFT96
|
15
|
+
# define NSEEDS 3
|
16
|
+
#else
|
17
|
+
# define NSEEDS 4
|
18
|
+
#endif
|
19
|
+
#define LASTSEED (NSEEDS-1)
|
13
20
|
|
14
21
|
#include <time.h>
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
MT_STATE_KEY, mrb_free,
|
20
|
-
};
|
21
|
-
|
22
|
-
static mrb_value mrb_random_rand(mrb_state *mrb, mrb_value self);
|
23
|
-
static mrb_value mrb_random_srand(mrb_state *mrb, mrb_value self);
|
23
|
+
typedef struct rand_state {
|
24
|
+
uint32_t seed[NSEEDS];
|
25
|
+
} rand_state;
|
24
26
|
|
25
27
|
static void
|
26
|
-
|
28
|
+
rand_init(rand_state *t)
|
27
29
|
{
|
28
|
-
|
30
|
+
t->seed[0] = 123456789;
|
31
|
+
t->seed[1] = 362436069;
|
32
|
+
t->seed[2] = 521288629;
|
33
|
+
#ifndef XORSHIFT96
|
34
|
+
t->seed[3] = 88675123;
|
35
|
+
#endif
|
29
36
|
}
|
30
37
|
|
31
|
-
static
|
32
|
-
|
38
|
+
static uint32_t
|
39
|
+
rand_seed(rand_state *t, uint32_t seed)
|
33
40
|
{
|
34
|
-
|
41
|
+
uint32_t old_seed = t->seed[LASTSEED];
|
42
|
+
rand_init(t);
|
43
|
+
t->seed[LASTSEED] = seed;
|
44
|
+
return old_seed;
|
35
45
|
}
|
36
46
|
|
37
|
-
|
38
|
-
|
47
|
+
#ifdef XORSHIFT96
|
48
|
+
static uint32_t
|
49
|
+
rand_uint32(rand_state *state)
|
39
50
|
{
|
40
|
-
|
51
|
+
uint32_t *seed = state->seed;
|
52
|
+
uint32_t x = seed[0];
|
53
|
+
uint32_t y = seed[1];
|
54
|
+
uint32_t z = seed[2];
|
55
|
+
uint32_t t;
|
56
|
+
|
57
|
+
t = (x ^ (x << 3)) ^ (y ^ (y >> 19)) ^ (z ^ (z << 6));
|
58
|
+
x = y; y = z; z = t;
|
59
|
+
seed[0] = x;
|
60
|
+
seed[1] = y;
|
61
|
+
seed[2] = z;
|
62
|
+
|
63
|
+
return z;
|
41
64
|
}
|
42
|
-
|
43
|
-
static
|
44
|
-
|
65
|
+
#else /* XORSHIFT96 */
|
66
|
+
static uint32_t
|
67
|
+
rand_uint32(rand_state *state)
|
45
68
|
{
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
69
|
+
uint32_t *seed = state->seed;
|
70
|
+
uint32_t x = seed[0];
|
71
|
+
uint32_t y = seed[1];
|
72
|
+
uint32_t z = seed[2];
|
73
|
+
uint32_t w = seed[3];
|
74
|
+
uint32_t t;
|
75
|
+
|
76
|
+
t = x ^ (x << 11);
|
77
|
+
x = y; y = z; z = w;
|
78
|
+
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
|
79
|
+
seed[0] = x;
|
80
|
+
seed[1] = y;
|
81
|
+
seed[2] = z;
|
82
|
+
seed[3] = w;
|
83
|
+
|
84
|
+
return w;
|
85
|
+
}
|
86
|
+
#endif /* XORSHIFT96 */
|
54
87
|
|
55
|
-
|
88
|
+
#ifndef MRB_WITHOUT_FLOAT
|
89
|
+
static double
|
90
|
+
rand_real(rand_state *t)
|
91
|
+
{
|
92
|
+
uint32_t x = rand_uint32(t);
|
93
|
+
return x*(1.0/4294967295.0);
|
56
94
|
}
|
95
|
+
#endif
|
57
96
|
|
58
97
|
static mrb_value
|
59
|
-
|
98
|
+
random_rand(mrb_state *mrb, rand_state *t, mrb_value max)
|
60
99
|
{
|
61
100
|
mrb_value value;
|
62
101
|
|
63
102
|
if (mrb_fixnum(max) == 0) {
|
64
|
-
|
103
|
+
#ifndef MRB_WITHOUT_FLOAT
|
104
|
+
value = mrb_float_value(mrb, rand_real(t));
|
105
|
+
#else
|
106
|
+
mrb_raise(mrb, E_ARGUMENT_ERROR, "Float not supported");
|
107
|
+
#endif
|
65
108
|
}
|
66
109
|
else {
|
67
|
-
value = mrb_fixnum_value(
|
110
|
+
value = mrb_fixnum_value(rand_uint32(t) % mrb_fixnum(max));
|
68
111
|
}
|
69
112
|
|
70
113
|
return value;
|
@@ -90,106 +133,74 @@ get_opt(mrb_state* mrb)
|
|
90
133
|
return arg;
|
91
134
|
}
|
92
135
|
|
93
|
-
static
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
}
|
99
|
-
|
100
|
-
static mt_state *
|
101
|
-
get_random_state(mrb_state *mrb)
|
102
|
-
{
|
103
|
-
mrb_value random_val = get_random(mrb);
|
104
|
-
return DATA_GET_PTR(mrb, random_val, &mt_state_type, mt_state);
|
136
|
+
static void
|
137
|
+
random_check(mrb_state *mrb, mrb_value random) {
|
138
|
+
struct RClass *c = mrb_class_get(mrb, "Random");
|
139
|
+
if (!mrb_obj_is_kind_of(mrb, random, c) || !mrb_istruct_p(random)) {
|
140
|
+
mrb_raise(mrb, E_TYPE_ERROR, "Random instance required");
|
141
|
+
}
|
105
142
|
}
|
106
143
|
|
107
144
|
static mrb_value
|
108
|
-
|
109
|
-
|
110
|
-
mrb_value
|
111
|
-
|
145
|
+
random_default(mrb_state *mrb) {
|
146
|
+
struct RClass *c = mrb_class_get(mrb, "Random");
|
147
|
+
mrb_value d = mrb_const_get(mrb, mrb_obj_value(c), mrb_intern_lit(mrb, "DEFAULT"));
|
148
|
+
if (!mrb_obj_is_kind_of(mrb, d, c)) {
|
149
|
+
mrb_raise(mrb, E_TYPE_ERROR, "Random::DEFAULT replaced");
|
150
|
+
}
|
151
|
+
return d;
|
112
152
|
}
|
113
153
|
|
114
|
-
|
115
|
-
|
116
|
-
{
|
117
|
-
mrb_value random = get_random(mrb);
|
118
|
-
return mrb_random_srand(mrb, random);
|
119
|
-
}
|
154
|
+
#define random_ptr(v) (rand_state*)mrb_istruct_ptr(v)
|
155
|
+
#define random_default_state(mrb) random_ptr(random_default(mrb))
|
120
156
|
|
121
157
|
static mrb_value
|
122
|
-
|
158
|
+
random_m_init(mrb_state *mrb, mrb_value self)
|
123
159
|
{
|
124
160
|
mrb_value seed;
|
125
|
-
|
161
|
+
rand_state *t;
|
126
162
|
|
127
163
|
seed = get_opt(mrb);
|
128
|
-
|
129
164
|
/* avoid memory leaks */
|
130
|
-
t = (
|
131
|
-
if (t) {
|
132
|
-
mrb_free(mrb, t);
|
133
|
-
}
|
134
|
-
mrb_data_init(self, NULL, &mt_state_type);
|
135
|
-
|
136
|
-
t = (mt_state *)mrb_malloc(mrb, sizeof(mt_state));
|
137
|
-
t->mti = N + 1;
|
138
|
-
|
139
|
-
seed = mrb_random_mt_srand(mrb, t, seed);
|
165
|
+
t = random_ptr(self);
|
140
166
|
if (mrb_nil_p(seed)) {
|
141
|
-
t
|
167
|
+
rand_init(t);
|
142
168
|
}
|
143
169
|
else {
|
144
|
-
|
145
|
-
t->has_seed = TRUE;
|
146
|
-
t->seed = mrb_fixnum(seed);
|
170
|
+
rand_seed(t, (uint32_t)mrb_fixnum(seed));
|
147
171
|
}
|
148
172
|
|
149
|
-
mrb_data_init(self, t, &mt_state_type);
|
150
|
-
|
151
173
|
return self;
|
152
174
|
}
|
153
175
|
|
154
|
-
static void
|
155
|
-
mrb_random_rand_seed(mrb_state *mrb, mt_state *t)
|
156
|
-
{
|
157
|
-
if (!t->has_seed) {
|
158
|
-
mrb_random_mt_srand(mrb, t, mrb_nil_value());
|
159
|
-
}
|
160
|
-
}
|
161
|
-
|
162
176
|
static mrb_value
|
163
|
-
|
177
|
+
random_m_rand(mrb_state *mrb, mrb_value self)
|
164
178
|
{
|
165
179
|
mrb_value max;
|
166
|
-
|
180
|
+
rand_state *t = random_ptr(self);
|
167
181
|
|
168
182
|
max = get_opt(mrb);
|
169
|
-
|
170
|
-
return mrb_random_mt_rand(mrb, t, max);
|
183
|
+
return random_rand(mrb, t, max);
|
171
184
|
}
|
172
185
|
|
173
186
|
static mrb_value
|
174
|
-
|
187
|
+
random_m_srand(mrb_state *mrb, mrb_value self)
|
175
188
|
{
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
t->has_seed = FALSE;
|
189
|
+
uint32_t seed;
|
190
|
+
uint32_t old_seed;
|
191
|
+
mrb_value sv;
|
192
|
+
rand_state *t = random_ptr(self);
|
193
|
+
|
194
|
+
sv = get_opt(mrb);
|
195
|
+
if (mrb_nil_p(sv)) {
|
196
|
+
seed = (uint32_t)time(NULL) + rand_uint32(t);
|
185
197
|
}
|
186
198
|
else {
|
187
|
-
|
188
|
-
t->has_seed = TRUE;
|
189
|
-
t->seed = mrb_fixnum(seed);
|
199
|
+
seed = (uint32_t)mrb_fixnum(sv);
|
190
200
|
}
|
201
|
+
old_seed = rand_seed(t, seed);
|
191
202
|
|
192
|
-
return old_seed;
|
203
|
+
return mrb_fixnum_value((mrb_int)old_seed);
|
193
204
|
}
|
194
205
|
|
195
206
|
/*
|
@@ -203,25 +214,28 @@ static mrb_value
|
|
203
214
|
mrb_ary_shuffle_bang(mrb_state *mrb, mrb_value ary)
|
204
215
|
{
|
205
216
|
mrb_int i;
|
206
|
-
|
217
|
+
mrb_value max;
|
218
|
+
mrb_value r = mrb_nil_value();
|
219
|
+
rand_state *random;
|
207
220
|
|
208
221
|
if (RARRAY_LEN(ary) > 1) {
|
209
|
-
mrb_get_args(mrb, "|
|
222
|
+
mrb_get_args(mrb, "|o", &r);
|
210
223
|
|
211
|
-
if (
|
212
|
-
random =
|
224
|
+
if (mrb_nil_p(r)) {
|
225
|
+
random = random_default_state(mrb);
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
random_check(mrb, r);
|
229
|
+
random = random_ptr(r);
|
213
230
|
}
|
214
|
-
mrb_random_rand_seed(mrb, random);
|
215
|
-
|
216
231
|
mrb_ary_modify(mrb, mrb_ary_ptr(ary));
|
217
|
-
|
232
|
+
max = mrb_fixnum_value(RARRAY_LEN(ary));
|
218
233
|
for (i = RARRAY_LEN(ary) - 1; i > 0; i--) {
|
219
234
|
mrb_int j;
|
220
235
|
mrb_value *ptr = RARRAY_PTR(ary);
|
221
236
|
mrb_value tmp;
|
222
237
|
|
223
|
-
|
224
|
-
j = mrb_fixnum(mrb_random_mt_rand(mrb, random, mrb_fixnum_value(RARRAY_LEN(ary))));
|
238
|
+
j = mrb_fixnum(random_rand(mrb, random, max));
|
225
239
|
|
226
240
|
tmp = ptr[i];
|
227
241
|
ptr[i] = ptr[j];
|
@@ -268,15 +282,18 @@ mrb_ary_sample(mrb_state *mrb, mrb_value ary)
|
|
268
282
|
{
|
269
283
|
mrb_int n = 0;
|
270
284
|
mrb_bool given;
|
271
|
-
|
285
|
+
mrb_value r = mrb_nil_value();
|
286
|
+
rand_state *random;
|
272
287
|
mrb_int len;
|
273
288
|
|
274
|
-
mrb_get_args(mrb, "|i?
|
275
|
-
if (
|
276
|
-
random =
|
289
|
+
mrb_get_args(mrb, "|i?o", &n, &given, &r);
|
290
|
+
if (mrb_nil_p(r)) {
|
291
|
+
random = random_default_state(mrb);
|
292
|
+
}
|
293
|
+
else {
|
294
|
+
random_check(mrb, r);
|
295
|
+
random = random_ptr(r);
|
277
296
|
}
|
278
|
-
mrb_random_rand_seed(mrb, random);
|
279
|
-
mt_rand(random);
|
280
297
|
len = RARRAY_LEN(ary);
|
281
298
|
if (!given) { /* pick one element */
|
282
299
|
switch (len) {
|
@@ -285,7 +302,7 @@ mrb_ary_sample(mrb_state *mrb, mrb_value ary)
|
|
285
302
|
case 1:
|
286
303
|
return RARRAY_PTR(ary)[0];
|
287
304
|
default:
|
288
|
-
return RARRAY_PTR(ary)[
|
305
|
+
return RARRAY_PTR(ary)[rand_uint32(random) % len];
|
289
306
|
}
|
290
307
|
}
|
291
308
|
else {
|
@@ -300,7 +317,7 @@ mrb_ary_sample(mrb_state *mrb, mrb_value ary)
|
|
300
317
|
|
301
318
|
for (;;) {
|
302
319
|
retry:
|
303
|
-
r =
|
320
|
+
r = (mrb_int)(rand_uint32(random) % len);
|
304
321
|
|
305
322
|
for (j=0; j<i; j++) {
|
306
323
|
if (mrb_fixnum(RARRAY_PTR(result)[j]) == r) {
|
@@ -318,23 +335,39 @@ mrb_ary_sample(mrb_state *mrb, mrb_value ary)
|
|
318
335
|
}
|
319
336
|
}
|
320
337
|
|
338
|
+
static mrb_value
|
339
|
+
random_f_rand(mrb_state *mrb, mrb_value self)
|
340
|
+
{
|
341
|
+
rand_state *t = random_default_state(mrb);
|
342
|
+
return random_rand(mrb, t, get_opt(mrb));
|
343
|
+
}
|
344
|
+
|
345
|
+
static mrb_value
|
346
|
+
random_f_srand(mrb_state *mrb, mrb_value self)
|
347
|
+
{
|
348
|
+
mrb_value random = random_default(mrb);
|
349
|
+
return random_m_srand(mrb, random);
|
350
|
+
}
|
351
|
+
|
321
352
|
|
322
353
|
void mrb_mruby_random_gem_init(mrb_state *mrb)
|
323
354
|
{
|
324
355
|
struct RClass *random;
|
325
356
|
struct RClass *array = mrb->array_class;
|
326
357
|
|
327
|
-
|
328
|
-
|
358
|
+
mrb_assert(sizeof(rand_state) <= ISTRUCT_DATA_SIZE);
|
359
|
+
|
360
|
+
mrb_define_method(mrb, mrb->kernel_module, "rand", random_f_rand, MRB_ARGS_OPT(1));
|
361
|
+
mrb_define_method(mrb, mrb->kernel_module, "srand", random_f_srand, MRB_ARGS_OPT(1));
|
329
362
|
|
330
363
|
random = mrb_define_class(mrb, "Random", mrb->object_class);
|
331
|
-
MRB_SET_INSTANCE_TT(random,
|
332
|
-
mrb_define_class_method(mrb, random, "rand",
|
333
|
-
mrb_define_class_method(mrb, random, "srand",
|
364
|
+
MRB_SET_INSTANCE_TT(random, MRB_TT_ISTRUCT);
|
365
|
+
mrb_define_class_method(mrb, random, "rand", random_f_rand, MRB_ARGS_OPT(1));
|
366
|
+
mrb_define_class_method(mrb, random, "srand", random_f_srand, MRB_ARGS_OPT(1));
|
334
367
|
|
335
|
-
mrb_define_method(mrb, random, "initialize",
|
336
|
-
mrb_define_method(mrb, random, "rand",
|
337
|
-
mrb_define_method(mrb, random, "srand",
|
368
|
+
mrb_define_method(mrb, random, "initialize", random_m_init, MRB_ARGS_OPT(1));
|
369
|
+
mrb_define_method(mrb, random, "rand", random_m_rand, MRB_ARGS_OPT(1));
|
370
|
+
mrb_define_method(mrb, random, "srand", random_m_srand, MRB_ARGS_OPT(1));
|
338
371
|
|
339
372
|
mrb_define_method(mrb, array, "shuffle", mrb_ary_shuffle, MRB_ARGS_OPT(1));
|
340
373
|
mrb_define_method(mrb, array, "shuffle!", mrb_ary_shuffle_bang, MRB_ARGS_OPT(1));
|