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
@@ -4,8 +4,10 @@
|
|
4
4
|
** See Copyright Notice in mruby.h
|
5
5
|
*/
|
6
6
|
|
7
|
+
#ifndef MRB_WITHOUT_FLOAT
|
7
8
|
#include <math.h>
|
8
|
-
#
|
9
|
+
#endif
|
10
|
+
|
9
11
|
#include <mruby.h>
|
10
12
|
#include <mruby/class.h>
|
11
13
|
#include <mruby/data.h>
|
@@ -17,7 +19,10 @@
|
|
17
19
|
#include <string.h>
|
18
20
|
#endif
|
19
21
|
|
22
|
+
#include <stdlib.h>
|
23
|
+
|
20
24
|
#define NDIV(x,y) (-(-((x)+1)/(y))-1)
|
25
|
+
#define TO_S_FMT "%Y-%m-%d %H:%M:%S "
|
21
26
|
|
22
27
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
23
28
|
double round(double x) {
|
@@ -25,8 +30,10 @@ double round(double x) {
|
|
25
30
|
}
|
26
31
|
#endif
|
27
32
|
|
28
|
-
#
|
29
|
-
#
|
33
|
+
#ifndef MRB_WITHOUT_FLOAT
|
34
|
+
# if !defined(__MINGW64__) && defined(_WIN32)
|
35
|
+
# define llround(x) round(x)
|
36
|
+
# endif
|
30
37
|
#endif
|
31
38
|
|
32
39
|
#if defined(__MINGW64__) || defined(__MINGW32__)
|
@@ -197,6 +204,76 @@ struct mrb_time {
|
|
197
204
|
|
198
205
|
static const struct mrb_data_type mrb_time_type = { "Time", mrb_free };
|
199
206
|
|
207
|
+
#ifndef MRB_WITHOUT_FLOAT
|
208
|
+
void mrb_check_num_exact(mrb_state *mrb, mrb_float num);
|
209
|
+
typedef mrb_float mrb_sec;
|
210
|
+
#define mrb_sec_value(mrb, sec) mrb_float_value(mrb, sec)
|
211
|
+
#else
|
212
|
+
typedef mrb_int mrb_sec;
|
213
|
+
#define mrb_sec_value(mrb, sec) mrb_fixnum_value(sec)
|
214
|
+
#endif
|
215
|
+
|
216
|
+
#ifdef MRB_TIME_T_UINT
|
217
|
+
typedef uint64_t mrb_time_int;
|
218
|
+
# define MRB_TIME_MIN 0
|
219
|
+
# define MRB_TIME_MAX (sizeof(time_t) <= 4 ? UINT32_MAX : UINT64_MAX)
|
220
|
+
#else
|
221
|
+
typedef int64_t mrb_time_int;
|
222
|
+
# define MRB_TIME_MIN (sizeof(time_t) <= 4 ? INT32_MIN : INT64_MIN)
|
223
|
+
# define MRB_TIME_MAX (sizeof(time_t) <= 4 ? INT32_MAX : INT64_MAX)
|
224
|
+
#endif
|
225
|
+
|
226
|
+
static time_t
|
227
|
+
mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec)
|
228
|
+
{
|
229
|
+
time_t t;
|
230
|
+
|
231
|
+
switch (mrb_type(obj)) {
|
232
|
+
#ifndef MRB_WITHOUT_FLOAT
|
233
|
+
case MRB_TT_FLOAT:
|
234
|
+
{
|
235
|
+
mrb_float f = mrb_float(obj);
|
236
|
+
|
237
|
+
mrb_check_num_exact(mrb, f);
|
238
|
+
if (f > (mrb_float)MRB_TIME_MAX || (mrb_float)MRB_TIME_MIN > f) {
|
239
|
+
goto out_of_range;
|
240
|
+
}
|
241
|
+
|
242
|
+
if (usec) {
|
243
|
+
t = (time_t)f;
|
244
|
+
*usec = (time_t)llround((f - t) * 1.0e+6);
|
245
|
+
}
|
246
|
+
else {
|
247
|
+
t = (time_t)llround(f);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
break;
|
251
|
+
#endif /* MRB_WITHOUT_FLOAT */
|
252
|
+
default:
|
253
|
+
case MRB_TT_FIXNUM:
|
254
|
+
{
|
255
|
+
mrb_int i = mrb_int(mrb, obj);
|
256
|
+
|
257
|
+
if ((mrb_time_int)i > MRB_TIME_MAX || MRB_TIME_MIN > i) {
|
258
|
+
goto out_of_range;
|
259
|
+
}
|
260
|
+
|
261
|
+
t = (time_t)i;
|
262
|
+
if (usec) { *usec = 0; }
|
263
|
+
}
|
264
|
+
break;
|
265
|
+
}
|
266
|
+
|
267
|
+
return t;
|
268
|
+
|
269
|
+
out_of_range:
|
270
|
+
mrb_raisef(mrb, E_ARGUMENT_ERROR, "%v out of Time range", obj);
|
271
|
+
|
272
|
+
/* not reached */
|
273
|
+
if (usec) { *usec = 0; }
|
274
|
+
return 0;
|
275
|
+
}
|
276
|
+
|
200
277
|
/** Updates the datetime of a mrb_time based on it's timezone and
|
201
278
|
seconds setting. Returns self on success, NULL of failure.
|
202
279
|
if `dealloc` is set `true`, it frees `self` on error. */
|
@@ -204,18 +281,19 @@ static struct mrb_time*
|
|
204
281
|
time_update_datetime(mrb_state *mrb, struct mrb_time *self, int dealloc)
|
205
282
|
{
|
206
283
|
struct tm *aid;
|
284
|
+
time_t t = self->sec;
|
207
285
|
|
208
286
|
if (self->timezone == MRB_TIMEZONE_UTC) {
|
209
|
-
aid = gmtime_r(&
|
287
|
+
aid = gmtime_r(&t, &self->datetime);
|
210
288
|
}
|
211
289
|
else {
|
212
|
-
aid = localtime_r(&
|
290
|
+
aid = localtime_r(&t, &self->datetime);
|
213
291
|
}
|
214
292
|
if (!aid) {
|
215
|
-
|
293
|
+
mrb_sec sec = (mrb_sec)t;
|
216
294
|
|
217
|
-
mrb_free(mrb, self);
|
218
|
-
mrb_raisef(mrb, E_ARGUMENT_ERROR, "%
|
295
|
+
if (dealloc) mrb_free(mrb, self);
|
296
|
+
mrb_raisef(mrb, E_ARGUMENT_ERROR, "%v out of Time range", mrb_sec_value(mrb, sec));
|
219
297
|
/* not reached */
|
220
298
|
return NULL;
|
221
299
|
}
|
@@ -232,40 +310,15 @@ mrb_time_wrap(mrb_state *mrb, struct RClass *tc, struct mrb_time *tm)
|
|
232
310
|
return mrb_obj_value(Data_Wrap_Struct(mrb, tc, &mrb_time_type, tm));
|
233
311
|
}
|
234
312
|
|
235
|
-
void mrb_check_num_exact(mrb_state *mrb, mrb_float num);
|
236
|
-
|
237
313
|
/* Allocates a mrb_time object and initializes it. */
|
238
314
|
static struct mrb_time*
|
239
|
-
|
315
|
+
time_alloc_time(mrb_state *mrb, time_t sec, time_t usec, enum mrb_timezone timezone)
|
240
316
|
{
|
241
317
|
struct mrb_time *tm;
|
242
|
-
time_t tsec = 0;
|
243
318
|
|
244
|
-
mrb_check_num_exact(mrb, (mrb_float)sec);
|
245
|
-
mrb_check_num_exact(mrb, (mrb_float)usec);
|
246
|
-
#ifndef MRB_TIME_T_UINT
|
247
|
-
if (sizeof(time_t) == 4 && (sec > (double)INT32_MAX || (double)INT32_MIN > sec)) {
|
248
|
-
goto out_of_range;
|
249
|
-
}
|
250
|
-
if (sizeof(time_t) == 8 && (sec > (double)INT64_MAX || (double)INT64_MIN > sec)) {
|
251
|
-
goto out_of_range;
|
252
|
-
}
|
253
|
-
#else
|
254
|
-
if (sizeof(time_t) == 4 && (sec > (double)UINT32_MAX || (double)0 > sec)) {
|
255
|
-
goto out_of_range;
|
256
|
-
}
|
257
|
-
if (sizeof(time_t) == 8 && (sec > (double)UINT64_MAX || (double)0 > sec)) {
|
258
|
-
goto out_of_range;
|
259
|
-
}
|
260
|
-
#endif
|
261
|
-
tsec = (time_t)sec;
|
262
|
-
if ((sec > 0 && tsec < 0) || (sec < 0 && (double)tsec > sec)) {
|
263
|
-
out_of_range:
|
264
|
-
mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S out of Time range", mrb_float_value(mrb, sec));
|
265
|
-
}
|
266
319
|
tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(struct mrb_time));
|
267
|
-
tm->sec =
|
268
|
-
tm->usec =
|
320
|
+
tm->sec = sec;
|
321
|
+
tm->usec = usec;
|
269
322
|
if (tm->usec < 0) {
|
270
323
|
long sec2 = (long)NDIV(tm->usec,1000000); /* negative div */
|
271
324
|
tm->usec -= sec2 * 1000000;
|
@@ -282,8 +335,25 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone)
|
|
282
335
|
return tm;
|
283
336
|
}
|
284
337
|
|
338
|
+
static struct mrb_time*
|
339
|
+
time_alloc(mrb_state *mrb, mrb_value sec, mrb_value usec, enum mrb_timezone timezone)
|
340
|
+
{
|
341
|
+
time_t tsec, tusec;
|
342
|
+
|
343
|
+
tsec = mrb_to_time_t(mrb, sec, &tusec);
|
344
|
+
tusec += mrb_to_time_t(mrb, usec, NULL);
|
345
|
+
|
346
|
+
return time_alloc_time(mrb, tsec, tusec, timezone);
|
347
|
+
}
|
348
|
+
|
349
|
+
static mrb_value
|
350
|
+
mrb_time_make_time(mrb_state *mrb, struct RClass *c, time_t sec, time_t usec, enum mrb_timezone timezone)
|
351
|
+
{
|
352
|
+
return mrb_time_wrap(mrb, c, time_alloc_time(mrb, sec, usec, timezone));
|
353
|
+
}
|
354
|
+
|
285
355
|
static mrb_value
|
286
|
-
mrb_time_make(mrb_state *mrb, struct RClass *c,
|
356
|
+
mrb_time_make(mrb_state *mrb, struct RClass *c, mrb_value sec, mrb_value usec, enum mrb_timezone timezone)
|
287
357
|
{
|
288
358
|
return mrb_time_wrap(mrb, c, time_alloc(mrb, sec, usec, timezone));
|
289
359
|
}
|
@@ -291,43 +361,46 @@ mrb_time_make(mrb_state *mrb, struct RClass *c, double sec, double usec, enum mr
|
|
291
361
|
static struct mrb_time*
|
292
362
|
current_mrb_time(mrb_state *mrb)
|
293
363
|
{
|
364
|
+
struct mrb_time tmzero = {0};
|
294
365
|
struct mrb_time *tm;
|
366
|
+
time_t sec, usec;
|
295
367
|
|
296
|
-
tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm));
|
297
368
|
#if defined(TIME_UTC) && !defined(__ANDROID__)
|
298
369
|
{
|
299
370
|
struct timespec ts;
|
300
371
|
if (timespec_get(&ts, TIME_UTC) == 0) {
|
301
|
-
mrb_free(mrb, tm);
|
302
372
|
mrb_raise(mrb, E_RUNTIME_ERROR, "timespec_get() failed for unknown reasons");
|
303
373
|
}
|
304
|
-
|
305
|
-
|
374
|
+
sec = ts.tv_sec;
|
375
|
+
usec = ts.tv_nsec / 1000;
|
306
376
|
}
|
307
377
|
#elif defined(NO_GETTIMEOFDAY)
|
308
378
|
{
|
309
379
|
static time_t last_sec = 0, last_usec = 0;
|
310
380
|
|
311
|
-
|
312
|
-
if (
|
313
|
-
last_sec =
|
381
|
+
sec = time(NULL);
|
382
|
+
if (sec != last_sec) {
|
383
|
+
last_sec = sec;
|
314
384
|
last_usec = 0;
|
315
385
|
}
|
316
386
|
else {
|
317
387
|
/* add 1 usec to differentiate two times */
|
318
388
|
last_usec += 1;
|
319
389
|
}
|
320
|
-
|
390
|
+
usec = last_usec;
|
321
391
|
}
|
322
392
|
#else
|
323
393
|
{
|
324
394
|
struct timeval tv;
|
325
395
|
|
326
396
|
gettimeofday(&tv, NULL);
|
327
|
-
|
328
|
-
|
397
|
+
sec = tv.tv_sec;
|
398
|
+
usec = tv.tv_usec;
|
329
399
|
}
|
330
400
|
#endif
|
401
|
+
tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm));
|
402
|
+
*tm = tmzero;
|
403
|
+
tm->sec = sec; tm->usec = usec;
|
331
404
|
tm->timezone = MRB_TIMEZONE_LOCAL;
|
332
405
|
time_update_datetime(mrb, tm, TRUE);
|
333
406
|
|
@@ -342,9 +415,9 @@ mrb_time_now(mrb_state *mrb, mrb_value self)
|
|
342
415
|
}
|
343
416
|
|
344
417
|
MRB_API mrb_value
|
345
|
-
mrb_time_at(mrb_state *mrb,
|
418
|
+
mrb_time_at(mrb_state *mrb, time_t sec, time_t usec, enum mrb_timezone zone)
|
346
419
|
{
|
347
|
-
return
|
420
|
+
return mrb_time_make_time(mrb, mrb_class_get(mrb, "Time"), sec, usec, zone);
|
348
421
|
}
|
349
422
|
|
350
423
|
/* 15.2.19.6.1 */
|
@@ -352,10 +425,12 @@ mrb_time_at(mrb_state *mrb, double sec, double usec, enum mrb_timezone zone)
|
|
352
425
|
static mrb_value
|
353
426
|
mrb_time_at_m(mrb_state *mrb, mrb_value self)
|
354
427
|
{
|
355
|
-
|
428
|
+
mrb_value sec;
|
429
|
+
mrb_value usec = mrb_fixnum_value(0);
|
430
|
+
|
431
|
+
mrb_get_args(mrb, "o|o", &sec, &usec);
|
356
432
|
|
357
|
-
|
358
|
-
return mrb_time_make(mrb, mrb_class_ptr(self), f, f2, MRB_TIMEZONE_LOCAL);
|
433
|
+
return mrb_time_make(mrb, mrb_class_ptr(self), sec, usec, MRB_TIMEZONE_LOCAL);
|
359
434
|
}
|
360
435
|
|
361
436
|
static struct mrb_time*
|
@@ -392,7 +467,7 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday,
|
|
392
467
|
mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time.");
|
393
468
|
}
|
394
469
|
|
395
|
-
return
|
470
|
+
return time_alloc_time(mrb, nowsecs, ausec, timezone);
|
396
471
|
}
|
397
472
|
|
398
473
|
/* 15.2.19.6.2 */
|
@@ -478,18 +553,19 @@ mrb_time_cmp(mrb_state *mrb, mrb_value self)
|
|
478
553
|
static mrb_value
|
479
554
|
mrb_time_plus(mrb_state *mrb, mrb_value self)
|
480
555
|
{
|
481
|
-
|
556
|
+
mrb_value o;
|
482
557
|
struct mrb_time *tm;
|
558
|
+
time_t sec, usec;
|
483
559
|
|
484
|
-
mrb_get_args(mrb, "
|
560
|
+
mrb_get_args(mrb, "o", &o);
|
485
561
|
tm = time_get_ptr(mrb, self);
|
486
|
-
|
562
|
+
sec = mrb_to_time_t(mrb, o, &usec);
|
563
|
+
return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), tm->sec+sec, tm->usec+usec, tm->timezone);
|
487
564
|
}
|
488
565
|
|
489
566
|
static mrb_value
|
490
567
|
mrb_time_minus(mrb_state *mrb, mrb_value self)
|
491
568
|
{
|
492
|
-
mrb_float f;
|
493
569
|
mrb_value other;
|
494
570
|
struct mrb_time *tm, *tm2;
|
495
571
|
|
@@ -497,13 +573,22 @@ mrb_time_minus(mrb_state *mrb, mrb_value self)
|
|
497
573
|
tm = time_get_ptr(mrb, self);
|
498
574
|
tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
|
499
575
|
if (tm2) {
|
500
|
-
|
501
|
-
|
576
|
+
#ifndef MRB_WITHOUT_FLOAT
|
577
|
+
mrb_float f;
|
578
|
+
f = (mrb_sec)(tm->sec - tm2->sec)
|
579
|
+
+ (mrb_sec)(tm->usec - tm2->usec) / 1.0e6;
|
502
580
|
return mrb_float_value(mrb, f);
|
581
|
+
#else
|
582
|
+
mrb_int f;
|
583
|
+
f = tm->sec - tm2->sec;
|
584
|
+
if (tm->usec < tm2->usec) f--;
|
585
|
+
return mrb_fixnum_value(f);
|
586
|
+
#endif
|
503
587
|
}
|
504
588
|
else {
|
505
|
-
|
506
|
-
|
589
|
+
time_t sec, usec;
|
590
|
+
sec = mrb_to_time_t(mrb, other, &usec);
|
591
|
+
return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), tm->sec-sec, tm->usec-usec, tm->timezone);
|
507
592
|
}
|
508
593
|
}
|
509
594
|
|
@@ -576,10 +661,9 @@ mrb_time_asctime(mrb_state *mrb, mrb_value self)
|
|
576
661
|
#else
|
577
662
|
char buf[256];
|
578
663
|
|
579
|
-
len = snprintf(buf, sizeof(buf), "%s %s %
|
664
|
+
len = snprintf(buf, sizeof(buf), "%s %s %2d %02d:%02d:%02d %.4d",
|
580
665
|
wday_names[d->tm_wday], mon_names[d->tm_mon], d->tm_mday,
|
581
666
|
d->tm_hour, d->tm_min, d->tm_sec,
|
582
|
-
tm->timezone == MRB_TIMEZONE_UTC ? "UTC " : "",
|
583
667
|
d->tm_year + 1900);
|
584
668
|
#endif
|
585
669
|
return mrb_str_new(mrb, buf, len);
|
@@ -761,7 +845,7 @@ mrb_time_sec(mrb_state *mrb, mrb_value self)
|
|
761
845
|
return mrb_fixnum_value(tm->datetime.tm_sec);
|
762
846
|
}
|
763
847
|
|
764
|
-
|
848
|
+
#ifndef MRB_WITHOUT_FLOAT
|
765
849
|
/* 15.2.19.7.24 */
|
766
850
|
/* Returns a Float with the time since the epoch in seconds. */
|
767
851
|
static mrb_value
|
@@ -772,32 +856,37 @@ mrb_time_to_f(mrb_state *mrb, mrb_value self)
|
|
772
856
|
tm = time_get_ptr(mrb, self);
|
773
857
|
return mrb_float_value(mrb, (mrb_float)tm->sec + (mrb_float)tm->usec/1.0e6);
|
774
858
|
}
|
859
|
+
#endif
|
775
860
|
|
776
861
|
/* 15.2.19.7.25 */
|
777
|
-
/* Returns
|
862
|
+
/* Returns an Integer with the time since the epoch in seconds. */
|
778
863
|
static mrb_value
|
779
864
|
mrb_time_to_i(mrb_state *mrb, mrb_value self)
|
780
865
|
{
|
781
866
|
struct mrb_time *tm;
|
782
867
|
|
783
868
|
tm = time_get_ptr(mrb, self);
|
869
|
+
#ifndef MRB_WITHOUT_FLOAT
|
784
870
|
if (tm->sec > MRB_INT_MAX || tm->sec < MRB_INT_MIN) {
|
785
871
|
return mrb_float_value(mrb, (mrb_float)tm->sec);
|
786
872
|
}
|
873
|
+
#endif
|
787
874
|
return mrb_fixnum_value((mrb_int)tm->sec);
|
788
875
|
}
|
789
876
|
|
790
877
|
/* 15.2.19.7.26 */
|
791
|
-
/* Returns
|
878
|
+
/* Returns an Integer with the time since the epoch in microseconds. */
|
792
879
|
static mrb_value
|
793
880
|
mrb_time_usec(mrb_state *mrb, mrb_value self)
|
794
881
|
{
|
795
882
|
struct mrb_time *tm;
|
796
883
|
|
797
884
|
tm = time_get_ptr(mrb, self);
|
885
|
+
#ifndef MRB_WITHOUT_FLOAT
|
798
886
|
if (tm->usec > MRB_INT_MAX || tm->usec < MRB_INT_MIN) {
|
799
887
|
return mrb_float_value(mrb, (mrb_float)tm->usec);
|
800
888
|
}
|
889
|
+
#endif
|
801
890
|
return mrb_fixnum_value((mrb_int)tm->usec);
|
802
891
|
}
|
803
892
|
|
@@ -825,6 +914,46 @@ mrb_time_utc_p(mrb_state *mrb, mrb_value self)
|
|
825
914
|
return mrb_bool_value(tm->timezone == MRB_TIMEZONE_UTC);
|
826
915
|
}
|
827
916
|
|
917
|
+
static size_t
|
918
|
+
time_to_s_utc(mrb_state *mrb, struct mrb_time *tm, char *buf, size_t buf_len)
|
919
|
+
{
|
920
|
+
return strftime(buf, buf_len, TO_S_FMT "UTC", &tm->datetime);
|
921
|
+
}
|
922
|
+
|
923
|
+
static size_t
|
924
|
+
time_to_s_local(mrb_state *mrb, struct mrb_time *tm, char *buf, size_t buf_len)
|
925
|
+
{
|
926
|
+
#if defined(_MSC_VER) && _MSC_VER < 1900 || defined(__MINGW64__) || defined(__MINGW32__)
|
927
|
+
struct tm datetime = {0};
|
928
|
+
time_t utc_sec = timegm(&tm->datetime);
|
929
|
+
size_t len;
|
930
|
+
int offset;
|
931
|
+
|
932
|
+
if (utc_sec == (time_t)-1) {
|
933
|
+
mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time.");
|
934
|
+
}
|
935
|
+
offset = abs((int)(utc_sec - tm->sec) / 60);
|
936
|
+
datetime.tm_year = 100;
|
937
|
+
datetime.tm_hour = offset / 60;
|
938
|
+
datetime.tm_min = offset % 60;
|
939
|
+
len = strftime(buf, buf_len, TO_S_FMT, &tm->datetime);
|
940
|
+
buf[len++] = utc_sec < tm->sec ? '-' : '+';
|
941
|
+
|
942
|
+
return len + strftime(buf + len, buf_len - len, "%H%M", &datetime);
|
943
|
+
#else
|
944
|
+
return strftime(buf, buf_len, TO_S_FMT "%z", &tm->datetime);
|
945
|
+
#endif
|
946
|
+
}
|
947
|
+
|
948
|
+
static mrb_value
|
949
|
+
mrb_time_to_s(mrb_state *mrb, mrb_value self)
|
950
|
+
{
|
951
|
+
char buf[64];
|
952
|
+
struct mrb_time *tm = time_get_ptr(mrb, self);
|
953
|
+
mrb_bool utc = tm->timezone == MRB_TIMEZONE_UTC;
|
954
|
+
size_t len = (utc ? time_to_s_utc : time_to_s_local)(mrb, tm, buf, sizeof(buf));
|
955
|
+
return mrb_str_new(mrb, buf, len);
|
956
|
+
}
|
828
957
|
|
829
958
|
void
|
830
959
|
mrb_mruby_time_gem_init(mrb_state* mrb)
|
@@ -845,8 +974,8 @@ mrb_mruby_time_gem_init(mrb_state* mrb)
|
|
845
974
|
mrb_define_method(mrb, tc, "<=>" , mrb_time_cmp , MRB_ARGS_REQ(1)); /* 15.2.19.7.1 */
|
846
975
|
mrb_define_method(mrb, tc, "+" , mrb_time_plus , MRB_ARGS_REQ(1)); /* 15.2.19.7.2 */
|
847
976
|
mrb_define_method(mrb, tc, "-" , mrb_time_minus , MRB_ARGS_REQ(1)); /* 15.2.19.7.3 */
|
848
|
-
mrb_define_method(mrb, tc, "to_s" ,
|
849
|
-
mrb_define_method(mrb, tc, "inspect",
|
977
|
+
mrb_define_method(mrb, tc, "to_s" , mrb_time_to_s , MRB_ARGS_NONE());
|
978
|
+
mrb_define_method(mrb, tc, "inspect", mrb_time_to_s , MRB_ARGS_NONE());
|
850
979
|
mrb_define_method(mrb, tc, "asctime", mrb_time_asctime, MRB_ARGS_NONE()); /* 15.2.19.7.4 */
|
851
980
|
mrb_define_method(mrb, tc, "ctime" , mrb_time_asctime, MRB_ARGS_NONE()); /* 15.2.19.7.5 */
|
852
981
|
mrb_define_method(mrb, tc, "day" , mrb_time_day , MRB_ARGS_NONE()); /* 15.2.19.7.6 */
|
@@ -866,7 +995,9 @@ mrb_mruby_time_gem_init(mrb_state* mrb)
|
|
866
995
|
|
867
996
|
mrb_define_method(mrb, tc, "sec" , mrb_time_sec, MRB_ARGS_NONE()); /* 15.2.19.7.23 */
|
868
997
|
mrb_define_method(mrb, tc, "to_i", mrb_time_to_i, MRB_ARGS_NONE()); /* 15.2.19.7.25 */
|
998
|
+
#ifndef MRB_WITHOUT_FLOAT
|
869
999
|
mrb_define_method(mrb, tc, "to_f", mrb_time_to_f, MRB_ARGS_NONE()); /* 15.2.19.7.24 */
|
1000
|
+
#endif
|
870
1001
|
mrb_define_method(mrb, tc, "usec", mrb_time_usec, MRB_ARGS_NONE()); /* 15.2.19.7.26 */
|
871
1002
|
mrb_define_method(mrb, tc, "utc" , mrb_time_utc, MRB_ARGS_NONE()); /* 15.2.19.7.27 */
|
872
1003
|
mrb_define_method(mrb, tc, "utc?", mrb_time_utc_p,MRB_ARGS_NONE()); /* 15.2.19.7.28 */
|