├── .gitmodules
├── test
├── html
│ ├── hoge.rb
│ ├── issue_172
│ │ └── index.html
│ ├── issue_172_2
│ │ └── index.html
│ ├── add_handler.rb
│ ├── exit_worker.rb
│ ├── init_worker.rb
│ ├── output_filter_header
│ │ └── index.html
│ ├── set.rb
│ ├── issue-210.rb
│ ├── output_filter_builtin_header
│ │ └── index.html
│ ├── header_filter.rb
│ ├── image
│ │ └── matsumotory.png
│ ├── stream_lb.rb
│ ├── set_ssl_cert_and_key.rb
│ ├── set2.rb
│ ├── backtrace.rb
│ ├── filter_dynamic_arg.rb
│ ├── proxy.rb
│ └── unified_hello.rb
├── conf
│ └── auto-ssl
│ │ └── dehydrated_out
│ │ └── .gitkeep
└── t
│ └── issue-268-test.rb
├── mruby
├── CODEOWNERS
├── .prettierrc
├── minirake
├── mrbgems
│ ├── mruby-sleep
│ │ ├── example
│ │ │ └── sleep.rb
│ │ ├── mrbgem.rake
│ │ ├── README.md
│ │ └── test
│ │ │ └── sleep_test.rb
│ ├── default-no-fpu.gembox
│ ├── default-no-stdio.gembox
│ ├── mruby-test
│ │ └── README.md
│ ├── mruby-socket
│ │ ├── test
│ │ │ ├── tcpsocket.rb
│ │ │ ├── udpsocket.rb
│ │ │ ├── basicsocket.rb
│ │ │ ├── ipsocket.rb
│ │ │ └── socket.rb
│ │ ├── src
│ │ │ └── gen.rb
│ │ └── mrbgem.rake
│ ├── mruby-fiber
│ │ └── mrbgem.rake
│ ├── mruby-data
│ │ └── mrbgem.rake
│ ├── mruby-exit
│ │ └── mrbgem.rake
│ ├── mruby-math
│ │ └── mrbgem.rake
│ ├── mruby-random
│ │ └── mrbgem.rake
│ ├── mruby-time
│ │ ├── mrbgem.rake
│ │ └── include
│ │ │ └── mruby
│ │ │ └── time.h
│ ├── mruby-print
│ │ ├── mrbgem.rake
│ │ └── mrblib
│ │ │ └── print.rb
│ ├── mruby-struct
│ │ └── mrbgem.rake
│ ├── mruby-catch
│ │ ├── mrbgem.rake
│ │ └── mrblib
│ │ │ └── catch.rb
│ ├── mruby-dir
│ │ ├── mrbgem.rake
│ │ └── mrblib
│ │ │ └── dir.rb
│ ├── mruby-error
│ │ └── mrbgem.rake
│ ├── mruby-proc-ext
│ │ ├── mrbgem.rake
│ │ └── mrblib
│ │ │ └── proc.rb
│ ├── mruby-sprintf
│ │ ├── mrblib
│ │ │ └── string.rb
│ │ └── mrbgem.rake
│ ├── mruby-array-ext
│ │ └── mrbgem.rake
│ ├── mruby-class-ext
│ │ ├── mrbgem.rake
│ │ └── test
│ │ │ └── class.rb
│ ├── mruby-enum-ext
│ │ └── mrbgem.rake
│ ├── mruby-objectspace
│ │ └── mrbgem.rake
│ ├── mruby-range-ext
│ │ └── mrbgem.rake
│ ├── mruby-string-ext
│ │ ├── mrbgem.rake
│ │ └── test
│ │ │ ├── range.rb
│ │ │ └── numeric.rb
│ ├── mruby-symbol-ext
│ │ └── mrbgem.rake
│ ├── mruby-compar-ext
│ │ └── mrbgem.rake
│ ├── mruby-numeric-ext
│ │ ├── mrbgem.rake
│ │ └── test
│ │ │ └── numeric.rb
│ ├── mruby-set
│ │ ├── mruby-set.gem
│ │ ├── mrbgem.rake
│ │ ├── README.md
│ │ └── LICENSE
│ ├── mruby-kernel-ext
│ │ └── mrbgem.rake
│ ├── mruby-metaprog
│ │ └── mrbgem.rake
│ ├── mruby-test-inline-struct
│ │ └── mrbgem.rake
│ ├── mruby-errno
│ │ ├── mrbgem.rake
│ │ ├── mrblib
│ │ │ └── errno.rb
│ │ ├── src
│ │ │ └── gen.rb
│ │ └── README.md
│ ├── mruby-object-ext
│ │ ├── mrbgem.rake
│ │ ├── test
│ │ │ ├── nil.rb
│ │ │ └── object.rb
│ │ └── mrblib
│ │ │ └── object.rb
│ ├── mruby-toplevel-ext
│ │ ├── mrbgem.rake
│ │ ├── mrblib
│ │ │ └── toplevel.rb
│ │ └── test
│ │ │ └── toplevel.rb
│ ├── full-core.gembox
│ ├── mruby-pack
│ │ └── mrbgem.rake
│ ├── mruby-enumerator
│ │ └── mrbgem.rake
│ ├── mruby-hash-ext
│ │ └── mrbgem.rake
│ ├── mruby-rational
│ │ ├── mrblib
│ │ │ └── rational.rb
│ │ └── mrbgem.rake
│ ├── mruby-enum-chain
│ │ ├── mrbgem.rake
│ │ └── mrblib
│ │ │ └── chain.rb
│ ├── mruby-io
│ │ ├── mrblib
│ │ │ ├── file_constants.rb
│ │ │ └── kernel.rb
│ │ ├── mrbgem.rake
│ │ └── src
│ │ │ └── mruby_io_gem.c
│ ├── mruby-method
│ │ ├── mrbgem.rake
│ │ ├── mrblib
│ │ │ └── method.rb
│ │ └── README.md
│ ├── mruby-binding
│ │ ├── mrbgem.rake
│ │ └── test
│ │ │ └── binding.c
│ ├── mruby-complex
│ │ └── mrbgem.rake
│ ├── mruby-bin-debugger
│ │ ├── tools
│ │ │ └── mrdb
│ │ │ │ ├── apiprint.h
│ │ │ │ ├── apistring.h
│ │ │ │ ├── apilist.h
│ │ │ │ ├── mrdberror.h
│ │ │ │ ├── mrdbconf.h
│ │ │ │ ├── apistring.c
│ │ │ │ └── apibreak.h
│ │ └── mrbgem.rake
│ ├── mruby-bin-strip
│ │ └── mrbgem.rake
│ ├── mruby-enum-lazy
│ │ ├── mrbgem.rake
│ │ └── test
│ │ │ └── lazy.rb
│ ├── mruby-cmath
│ │ ├── mrbgem.rake
│ │ └── test
│ │ │ └── cmath.rb
│ ├── mruby-proc-binding
│ │ ├── test
│ │ │ ├── proc-binding.c
│ │ │ └── proc-binding.rb
│ │ ├── mrbgem.rake
│ │ └── src
│ │ │ └── proc-binding.c
│ ├── metaprog.gembox
│ ├── math.gembox
│ ├── mruby-bigint
│ │ ├── mrbgem.rake
│ │ ├── README.md
│ │ └── test
│ │ │ └── bigint.rb
│ ├── mruby-eval
│ │ └── mrbgem.rake
│ ├── mruby-bin-mruby
│ │ └── mrbgem.rake
│ ├── stdlib-io.gembox
│ ├── mruby-os-memsize
│ │ └── mrbgem.rake
│ ├── stdlib-ext.gembox
│ ├── mruby-bin-mrbc
│ │ ├── mrbgem.rake
│ │ └── bintest
│ │ │ └── mrbc.rb
│ ├── default.gembox
│ └── mruby-compiler
│ │ └── mrbgem.rake
├── src
│ ├── opcode.h
│ ├── error.h
│ ├── value_array.h
│ ├── enum.c
│ ├── version.c
│ ├── readint.c
│ ├── allocf.c
│ ├── readnum.c
│ └── init.c
├── test
│ ├── t
│ │ ├── vformat.rb
│ │ ├── regexperror.rb
│ │ ├── typeerror.rb
│ │ ├── indexerror.rb
│ │ ├── rangeerror.rb
│ │ ├── runtimeerror.rb
│ │ ├── standarderror.rb
│ │ ├── basicobject.rb
│ │ ├── object.rb
│ │ ├── localjumperror.rb
│ │ ├── nomethoderror.rb
│ │ ├── symbol.rb
│ │ ├── nameerror.rb
│ │ ├── true.rb
│ │ ├── bs_literal.rb
│ │ ├── false.rb
│ │ ├── ensure.rb
│ │ ├── nil.rb
│ │ ├── gc.rb
│ │ ├── argumenterror.rb
│ │ ├── iterations.rb
│ │ └── unicode.rb
│ └── bintest.rb
├── .gitattributes
├── benchmark
│ ├── bm_fib.rb
│ ├── plot.gpl
│ └── bm_so_lists.rb
├── doc
│ └── mruby_logo_red_icon.png
├── oss-fuzz
│ ├── config
│ │ ├── mruby_proto_fuzzer.options
│ │ └── mruby_fuzzer.options
│ ├── mruby_fuzzer.c
│ └── mruby_proto_fuzzer.cpp
├── examples
│ └── mrbgems
│ │ ├── c_extension_example
│ │ ├── README.md
│ │ ├── test
│ │ │ ├── example.rb
│ │ │ └── example.c
│ │ ├── src
│ │ │ └── example.c
│ │ └── mrbgem.rake
│ │ ├── ruby_extension_example
│ │ ├── test
│ │ │ └── example.rb
│ │ ├── README.md
│ │ ├── mrblib
│ │ │ └── example.rb
│ │ └── mrbgem.rake
│ │ ├── cdata_extension_example
│ │ ├── README.md
│ │ ├── test
│ │ │ └── example.c
│ │ └── mrbgem.rake
│ │ ├── c_and_ruby_extension_example
│ │ ├── README.md
│ │ ├── mrblib
│ │ │ └── example.rb
│ │ ├── test
│ │ │ └── example.rb
│ │ ├── src
│ │ │ └── example.c
│ │ └── mrbgem.rake
│ │ └── mruby-YOUR-bigint
│ │ └── mrbgem.rake
├── build_config
│ ├── minimal.rb
│ ├── mrbc.rb
│ ├── host-cxx.rb
│ ├── bench.rb
│ ├── android_arm64_v8a.rb
│ ├── clang-asan.rb
│ ├── host-gprof.rb
│ ├── host-f32.rb
│ ├── host-m32.rb
│ ├── android_armeabi_v7a_neon_hard.rb
│ ├── cross-32bit.rb
│ ├── host-debug.rb
│ ├── cross-mingw.rb
│ ├── host-nofloat.rb
│ ├── boxing.rb
│ ├── ci
│ │ ├── msvc.rb
│ │ └── gcc-clang.rb
│ ├── host-shared.rb
│ └── serenity.rb
├── Gemfile
├── mrblib
│ ├── symbol.rb
│ ├── 00class.rb
│ ├── 00kernel.rb
│ ├── kernel.rb
│ └── 10error.rb
├── .dockerignore
├── codespell.txt
├── .travis.yml
├── .git-blame-ignore-revs
├── include
│ └── mruby
│ │ ├── re.h
│ │ ├── endian.h
│ │ ├── istruct.h
│ │ ├── presym
│ │ └── enable.h
│ │ └── object.h
├── .github
│ ├── linters
│ │ ├── .yaml-lint.yml
│ │ ├── .ecrc
│ │ └── .markdown-lint.yml
│ ├── dependabot.yml
│ └── workflows
│ │ ├── labeler.yml
│ │ ├── oss-fuzz.yml
│ │ ├── lint.yml
│ │ └── super-linter.yml
├── tasks
│ ├── toolchains
│ │ ├── clang.rake
│ │ └── openwrt.rake
│ ├── core.rake
│ ├── bin.rake
│ ├── install.rake
│ └── mrblib.rake
├── docker-compose.yml
├── TODO.md
├── Dockerfile
├── .yardopts
├── .gitignore
├── Gemfile.lock
├── build_config.rb
├── SECURITY.md
├── mruby-source.gemspec
├── Makefile
├── .editorconfig
└── LICENSE
├── dependence
└── ngx_devel_kit
│ ├── auto
│ ├── data
│ │ ├── prefixes
│ │ ├── header_files
│ │ ├── headers
│ │ ├── action_replacements
│ │ ├── module_dependencies
│ │ ├── modules_optional
│ │ ├── conf_args
│ │ ├── contexts
│ │ ├── action_types
│ │ ├── conf_locs
│ │ └── conf_macros
│ ├── src
│ │ ├── palloc.h
│ │ └── array.h
│ ├── text
│ │ └── autogen
│ └── actions
│ │ ├── palloc
│ │ └── array
│ ├── .gitignore
│ ├── src
│ ├── ndk_log.c
│ ├── ndk_uri.h
│ ├── ndk_http.h
│ ├── ndk_buf.h
│ ├── ndk_encoding.h
│ ├── ndk_process.h
│ ├── ndk_regex.h
│ ├── ndk_process.c
│ ├── ndk_upstream_list.h
│ ├── ndk_string_util.h
│ ├── ndk_complex_value.h
│ ├── ndk_rewrite.h
│ ├── ndk_path.h
│ ├── ndk_buf.c
│ ├── ndk_uri.c
│ ├── ndk_hash.h
│ ├── ndk_complex_path.h
│ ├── ndk_string.h
│ ├── ndk.h
│ └── ndk_encoding.c
│ ├── examples
│ ├── http
│ │ └── set_var
│ │ │ └── config
│ └── README
│ ├── patches
│ ├── auto_config
│ └── rewrite_phase_handler
│ ├── notes
│ └── CHANGES
│ ├── docs
│ └── upstream
│ │ └── list
│ ├── objs
│ └── ndk_includes.h
│ └── LICENSE
├── docker
└── hook
│ ├── test.rb
│ └── proxy.rb
├── example
├── set.rb
├── README.md
├── set2.rb
├── proxy.rb
└── unified_hello.rb
├── mrbgems
├── auto-ssl
│ ├── test
│ │ └── mrb_nginx.rb
│ └── mrbgem.rake
├── ngx_mruby_mrblib
│ ├── test
│ │ └── mrb_nginx.rb
│ └── mrbgem.rake
└── rack-based-api
│ ├── test
│ └── mrb_nginx.rb
│ └── mrbgem.rake
├── misc
└── logo.png
├── apply-clang-format
├── nginx_version
├── Vagrantfile
├── LEGAL
├── .clang-format
├── AUTHORS
├── .gitignore
├── src
├── http
│ ├── ngx_http_mruby_init.h
│ ├── ngx_http_mruby_filter.h
│ ├── ngx_http_mruby_server.h
│ ├── ngx_http_mruby_connection.h
│ ├── ngx_http_mruby_ssl.h
│ ├── ngx_http_mruby_var.h
│ ├── ngx_http_mruby_request.h
│ └── ngx_http_mruby_async.h
└── stream
│ ├── ngx_stream_mruby_init.h
│ ├── ngx_stream_mruby_connection.h
│ ├── ngx_stream_mruby_async.h
│ ├── ngx_stream_mruby_core.h
│ └── ngx_stream_mruby_init.c
├── .vscode
└── c_cpp_properties.json
├── .github
└── PULL_REQUEST_TEMPLATE.md
├── update-mruby-subtree
├── update-devkit-subtree
├── MITL
└── docs
└── test
└── README.md
/.gitmodules:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/html/hoge.rb:
--------------------------------------------------------------------------------
1 | "aaa"
2 |
--------------------------------------------------------------------------------
/mruby/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @matz
2 |
--------------------------------------------------------------------------------
/test/html/issue_172/index.html:
--------------------------------------------------------------------------------
1 | hello
--------------------------------------------------------------------------------
/test/html/issue_172_2/index.html:
--------------------------------------------------------------------------------
1 | hello
--------------------------------------------------------------------------------
/test/conf/auto-ssl/dehydrated_out/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/html/add_handler.rb:
--------------------------------------------------------------------------------
1 | Nginx.rputs "add_handler"
2 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/prefixes:
--------------------------------------------------------------------------------
1 | ngx
2 | ndk
3 |
--------------------------------------------------------------------------------
/docker/hook/test.rb:
--------------------------------------------------------------------------------
1 | Nginx.echo "This is test for ngx_mruby"
2 |
--------------------------------------------------------------------------------
/mruby/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "bracketSpacing": false
3 | }
4 |
--------------------------------------------------------------------------------
/mruby/minirake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | exec "rake", *ARGV
3 |
--------------------------------------------------------------------------------
/test/html/exit_worker.rb:
--------------------------------------------------------------------------------
1 | p "[#{Process.pid}] exit worker!"
2 |
--------------------------------------------------------------------------------
/test/html/init_worker.rb:
--------------------------------------------------------------------------------
1 | p "[#{Process.pid}] init worker!"
2 |
--------------------------------------------------------------------------------
/test/html/output_filter_header/index.html:
--------------------------------------------------------------------------------
1 | output_filter_header
2 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/header_files:
--------------------------------------------------------------------------------
1 | array
2 | palloc
3 |
4 |
--------------------------------------------------------------------------------
/example/set.rb:
--------------------------------------------------------------------------------
1 | r = Nginx::Request.new
2 |
3 | r.var.fuga.to_i * 2
4 |
--------------------------------------------------------------------------------
/mrbgems/auto-ssl/test/mrb_nginx.rb:
--------------------------------------------------------------------------------
1 | ##
2 | ## Nginx Test
3 | ##
4 |
5 |
--------------------------------------------------------------------------------
/test/html/set.rb:
--------------------------------------------------------------------------------
1 | r = Nginx::Request.new
2 |
3 | r.var.fuga.to_i * 2
4 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/.gitignore:
--------------------------------------------------------------------------------
1 | tags
2 | cscope.*
3 | *~
4 | *.swp
5 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-sleep/example/sleep.rb:
--------------------------------------------------------------------------------
1 | sleep(10)
2 | usleep(10000)
3 |
--------------------------------------------------------------------------------
/test/html/issue-210.rb:
--------------------------------------------------------------------------------
1 | Nginx::Request.new.headers_out["fuga"] = "hoge"
2 |
--------------------------------------------------------------------------------
/misc/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matsumotory/ngx_mruby/HEAD/misc/logo.png
--------------------------------------------------------------------------------
/mrbgems/ngx_mruby_mrblib/test/mrb_nginx.rb:
--------------------------------------------------------------------------------
1 | ##
2 | ## Nginx Test
3 | ##
4 |
5 |
--------------------------------------------------------------------------------
/mrbgems/rack-based-api/test/mrb_nginx.rb:
--------------------------------------------------------------------------------
1 | ##
2 | ## Nginx Test
3 | ##
4 |
5 |
--------------------------------------------------------------------------------
/test/html/output_filter_builtin_header/index.html:
--------------------------------------------------------------------------------
1 | output_filter_builtin_header
2 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/headers:
--------------------------------------------------------------------------------
1 | http_headers
2 | log
3 | parse
4 | string_util
5 |
--------------------------------------------------------------------------------
/mruby/src/opcode.h:
--------------------------------------------------------------------------------
1 | /* this header file is to be removed soon. */
2 | #include
3 |
--------------------------------------------------------------------------------
/test/html/header_filter.rb:
--------------------------------------------------------------------------------
1 | Nginx::Request.new.headers_out["x-add-new-header"] = "new_header"
2 |
--------------------------------------------------------------------------------
/mruby/mrbgems/default-no-fpu.gembox:
--------------------------------------------------------------------------------
1 | MRuby::GemBox.new do |conf|
2 | conf.gembox "stdlib"
3 | end
4 |
--------------------------------------------------------------------------------
/mruby/test/t/vformat.rb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matsumotory/ngx_mruby/HEAD/mruby/test/t/vformat.rb
--------------------------------------------------------------------------------
/mruby/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 | *.bat text eol=crlf
3 | *.cmd text eol=crlf
4 | *.png binary
5 |
--------------------------------------------------------------------------------
/mruby/benchmark/bm_fib.rb:
--------------------------------------------------------------------------------
1 | def fib n
2 | return n if n < 2
3 | fib(n-2) + fib(n-1)
4 | end
5 |
6 | puts fib(37)
7 |
--------------------------------------------------------------------------------
/mruby/doc/mruby_logo_red_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matsumotory/ngx_mruby/HEAD/mruby/doc/mruby_logo_red_icon.png
--------------------------------------------------------------------------------
/mruby/oss-fuzz/config/mruby_proto_fuzzer.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | close_fd_mask = 3
3 | dict = mruby.dict
4 | fork = 1
5 |
--------------------------------------------------------------------------------
/test/html/image/matsumotory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matsumotory/ngx_mruby/HEAD/test/html/image/matsumotory.png
--------------------------------------------------------------------------------
/test/html/stream_lb.rb:
--------------------------------------------------------------------------------
1 | c = Nginx::Stream::Connection.new "dynamic_server1"
2 | c.upstream_server = "127.0.0.1:58080"
3 |
--------------------------------------------------------------------------------
/mruby/test/t/regexperror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # RegexpError ISO Test
3 |
4 | # TODO broken ATM assert('RegexpError', '15.2.27') do
5 |
--------------------------------------------------------------------------------
/mruby/mrbgems/default-no-stdio.gembox:
--------------------------------------------------------------------------------
1 | MRuby::GemBox.new do |conf|
2 | conf.gembox "stdlib"
3 | conf.gembox "math"
4 | end
5 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_log.c:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* TODO : the required functions if the compiler does not have variadic macros */
4 |
--------------------------------------------------------------------------------
/mruby/oss-fuzz/config/mruby_fuzzer.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | close_fd_mask = 3
3 | dict = mruby.dict
4 | fork = 1
5 | only_ascii = 1
6 |
--------------------------------------------------------------------------------
/apply-clang-format:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | for f in `ls src/{http,stream}/*.{c,h}`
6 | do
7 | clang-format -i $f
8 | done
9 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_extension_example/README.md:
--------------------------------------------------------------------------------
1 | # C Extension Example
2 |
3 | This is an example gem which implements a C extension.
4 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_extension_example/test/example.rb:
--------------------------------------------------------------------------------
1 | assert('C Extension Example') do
2 | CExtension.respond_to? :c_method
3 | end
4 |
--------------------------------------------------------------------------------
/mruby/src/error.h:
--------------------------------------------------------------------------------
1 | /* this header file is to be removed soon.
2 | added for compatibility purpose (1.0.0) */
3 | #include
4 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/action_replacements:
--------------------------------------------------------------------------------
1 |
2 | OK NGX_OK
3 | E NGX_ERROR
4 | CE NGX_CONF_ERROR
5 | COK NGX_CONF_OK
6 |
--------------------------------------------------------------------------------
/mruby/build_config/minimal.rb:
--------------------------------------------------------------------------------
1 | MRuby::CrossBuild.new('minimal') do |conf|
2 | conf.toolchain :gcc
3 | conf.cc.defines << 'MRB_NO_STDIO'
4 | end
5 |
--------------------------------------------------------------------------------
/mruby/test/t/typeerror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # TypeError ISO Test
3 |
4 | assert('TypeError', '15.2.29') do
5 | assert_equal Class, TypeError.class
6 | end
7 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/ruby_extension_example/test/example.rb:
--------------------------------------------------------------------------------
1 | assert('Ruby Extension Example') do
2 | RubyExtension.respond_to? :ruby_method
3 | end
4 |
--------------------------------------------------------------------------------
/mruby/test/t/indexerror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # IndexError ISO Test
3 |
4 | assert('IndexError', '15.2.33') do
5 | assert_equal Class, IndexError.class
6 | end
7 |
--------------------------------------------------------------------------------
/mruby/test/t/rangeerror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # RangeError ISO Test
3 |
4 | assert('RangeError', '15.2.26') do
5 | assert_equal Class, RangeError.class
6 | end
7 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/cdata_extension_example/README.md:
--------------------------------------------------------------------------------
1 | # C Data Extension Example
2 |
3 | This is an example gem which implements a C extension with Data.
4 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/ruby_extension_example/README.md:
--------------------------------------------------------------------------------
1 | # Pure Ruby Extension Example
2 |
3 | This is an example gem which implements a pure Ruby extension.
4 |
--------------------------------------------------------------------------------
/mruby/test/t/runtimeerror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # RuntimeError ISO Test
3 |
4 | assert('RuntimeError', '15.2.28') do
5 | assert_equal Class, RuntimeError.class
6 | end
7 |
--------------------------------------------------------------------------------
/nginx_version:
--------------------------------------------------------------------------------
1 | NGINX_SRC_MAJOR=1
2 | NGINX_SRC_MINOR=27
3 | NGINX_SRC_PATCH=2
4 | NGINX_SRC_VER=nginx-${NGINX_SRC_MAJOR}.${NGINX_SRC_MINOR}.${NGINX_SRC_PATCH}
5 |
--------------------------------------------------------------------------------
/mruby/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | source 'https://rubygems.org'
4 |
5 | gem 'rake'
6 | gem 'yard'
7 | gem 'yard-coderay'
8 | gem 'yard-mruby'
9 |
--------------------------------------------------------------------------------
/mruby/test/t/standarderror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # StandardError ISO Test
3 |
4 | assert('StandardError', '15.2.23') do
5 | assert_equal Class, StandardError.class
6 | end
7 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_and_ruby_extension_example/README.md:
--------------------------------------------------------------------------------
1 | # C and Ruby Extension Example
2 |
3 | This is an example gem which implements a C and Ruby extension.
4 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-test/README.md:
--------------------------------------------------------------------------------
1 | # Running Tests
2 |
3 | To run the tests, execute the following from the project's root directory.
4 |
5 | ```
6 | $ make test
7 | ```
8 |
--------------------------------------------------------------------------------
/mruby/mrblib/symbol.rb:
--------------------------------------------------------------------------------
1 | class Symbol
2 | def to_proc
3 | ->(obj,*args,**opts,&block) do
4 | obj.__send__(self, *args, **opts, &block)
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # Example
2 | ```bash
3 | cp set.rb set2.rb unified_hello.rb ${DOCROOT}/.
4 | cp nginx.conf ${NGINX_CONF_DIR}/.
5 | ```
6 | access some locations in nginx.conf
7 |
--------------------------------------------------------------------------------
/mrbgems/ngx_mruby_mrblib/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-ngx-mruby-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = 'MATSUMOTO Ryosuke'
4 | end
5 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb:
--------------------------------------------------------------------------------
1 | class RubyExtension
2 | def RubyExtension.ruby_method
3 | puts "#{self}: A Ruby Extension"
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | Vagrant.configure("2") do |config|
2 | config.vm.box = "bento/ubuntu-18.04"
3 | config.vm.provision "shell", :path => "misc/provision.sh", :privileged => false
4 | end
5 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_uri.h:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | u_char * ndk_map_uri_to_path_add_suffix (ngx_http_request_t *r, ngx_str_t *path, ngx_str_t *suffix, ngx_int_t dot);
5 |
6 |
7 |
--------------------------------------------------------------------------------
/mruby/.dockerignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .idea
3 | .vscode
4 | *.bak
5 | *.iml
6 | *.ipr
7 | *.swp
8 | *.tmp
9 |
10 | /.yardoc
11 | /bin
12 | /build
13 | /doc/api
14 | /doc/capi
15 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/test/tcpsocket.rb:
--------------------------------------------------------------------------------
1 | #assert('TCPSocket.gethostbyname') do
2 | #assert('TCPSocket.new') do
3 | #assert('TCPSocket#close') do
4 | #assert('TCPSocket#write') do
5 |
--------------------------------------------------------------------------------
/test/html/set_ssl_cert_and_key.rb:
--------------------------------------------------------------------------------
1 | ssl = Nginx::SSL.new
2 | ssl.certificate = "__NGXDOCROOT__/#{ssl.servername}.crt"
3 | ssl.certificate_key = "__NGXDOCROOT__/#{ssl.servername}.key"
4 |
--------------------------------------------------------------------------------
/mruby/codespell.txt:
--------------------------------------------------------------------------------
1 | ans
2 | celler
3 | clen
4 | delet
5 | disabl
6 | filetest
7 | fo
8 | hel
9 | ist
10 | nd
11 | quitt
12 | remore
13 | runn
14 | sting
15 | strin
16 | wronly
17 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb:
--------------------------------------------------------------------------------
1 | module CRubyExtension
2 | def CRubyExtension.ruby_method
3 | puts "#{self}: A Ruby Extension"
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_extension_example/test/example.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void
4 | mrb_c_extension_example_gem_test(mrb_state *mrb)
5 | {
6 | /* test initializer in C */
7 | }
8 |
--------------------------------------------------------------------------------
/LEGAL:
--------------------------------------------------------------------------------
1 | LEGAL NOTICE INFORMATION
2 | ------------------------
3 |
4 | All the files in this distribution are covered under the MIT license
5 | (see the file MITL) except some files mentioned below:
6 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_http.h:
--------------------------------------------------------------------------------
1 |
2 | ngx_uint_t ndk_http_count_phase_handlers (ngx_http_core_main_conf_t *cmcf);
3 | ngx_uint_t ndk_http_parse_request_method (ngx_str_t *m);
4 |
--------------------------------------------------------------------------------
/mruby/.travis.yml:
--------------------------------------------------------------------------------
1 | language: c
2 |
3 | jobs:
4 | - os: linux
5 | - os: osx
6 |
7 | env:
8 | - MRUBY_CONFIG=ci/gcc-clang
9 |
10 | script:
11 | - rake -m test:build && rake test:run
12 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/cdata_extension_example/test/example.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void
4 | mrb_cdata_extension_example_gem_test(mrb_state *mrb)
5 | {
6 | /* test initializer in C */
7 | }
8 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-fiber/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-fiber') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Fiber class'
5 | end
6 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | # requires clang-format >= 6.0
2 | BasedOnStyle: "LLVM"
3 | IndentWidth: 2
4 | ColumnLimit: 120
5 | BreakBeforeBraces: Linux
6 | AllowShortFunctionsOnASingleLine: None
7 | SortIncludes: false
8 |
--------------------------------------------------------------------------------
/mruby/benchmark/plot.gpl:
--------------------------------------------------------------------------------
1 | set yrange [0:]
2 | set terminal pngcairo font 'Sans, 8' lw 1 size 1400,1024
3 | set xtics rotate by -45
4 | set style histogram errorbars gap 2 lw 1
5 | set style fill solid border -1
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-data/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-data') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard Data class'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-exit/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-exit') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Kernel#exit method'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-math/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-math') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard Math module'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-random/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-random') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Random class'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-time/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-time') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard Time class'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-print/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-print') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard print/puts/p'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-struct/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-struct') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard Struct class'
5 | end
6 |
--------------------------------------------------------------------------------
/test/html/set2.rb:
--------------------------------------------------------------------------------
1 | r = Nginx::Request.new
2 |
3 | Nginx.rputs "fuga => #{r.var.fuga} "
4 | Nginx.rputs "hoge => #{r.var.hoge} "
5 |
6 | r.var.set "hoge", r.var.hoge.to_i * 2
7 | Nginx.rputs "hoge => #{r.var.hoge}"
8 |
--------------------------------------------------------------------------------
/AUTHORS:
--------------------------------------------------------------------------------
1 | Original Authors "ngx_mruby developers" are:
2 | MATSUMOTO Ryosuke
3 | Tatsuhiko Kubo
4 | SHIBATA Hiroshi
5 | SAWANOBORI Yukihiko
6 | OKUMURA Takahiro
7 | Yuji Yamano
8 | Kazuhiko Yamashita
9 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/module_dependencies:
--------------------------------------------------------------------------------
1 | complex_path complex_value path
2 | conf_file string
3 | hash string
4 | set_var rewrite
5 | upstream_list http_create_main_conf
6 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_buf.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | ngx_int_t ndk_copy_chain_to_str (ngx_pool_t *pool, ngx_chain_t *in, ngx_str_t *str);
4 | char * ndk_copy_chain_to_charp (ngx_pool_t *pool, ngx_chain_t *in);
5 |
6 |
--------------------------------------------------------------------------------
/example/set2.rb:
--------------------------------------------------------------------------------
1 | r = Nginx::Request.new
2 |
3 | Nginx.rputs "fuga => #{r.var.fuga} "
4 | Nginx.rputs "hoge => #{r.var.hoge} "
5 |
6 | r.var.set "hoge", r.var.hoge.to_i * 2
7 | Nginx.rputs "hoge => #{r.var.hoge} "
8 |
9 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-catch/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-catch') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Catch / Throw non-local Jump'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-dir/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-dir') do |spec|
2 | spec.license = 'MIT and MIT-like license'
3 | spec.authors = ['Internet Initiative Japan Inc.', 'Kevlin Henney']
4 | end
5 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-error/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-error') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'extensional error handling'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-proc-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-proc-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Proc class extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-sprintf/mrblib/string.rb:
--------------------------------------------------------------------------------
1 | class String
2 | def %(args)
3 | if args.is_a? Array
4 | sprintf(self, *args)
5 | else
6 | sprintf(self, args)
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-array-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-array-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Array class extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-class-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-class-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'class/module extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-enum-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-enum-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Enumerable module extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-objectspace/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-objectspace') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'ObjectSpace class'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-range-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-range-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Range class extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-string-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-string-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'String class extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-symbol-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Symbol class extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-compar-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-compar-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Comparable module extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-numeric-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Numeric class extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-set/mruby-set.gem:
--------------------------------------------------------------------------------
1 | name: mruby-set
2 | description: Set class
3 | author: yui-knk
4 | website: https://github.com/yui-knk/mruby-set
5 | protocol: git
6 | repository: https://github.com/yui-knk/mruby-set.git
7 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-sprintf/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-sprintf') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard Kernel#sprintf method'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-kernel-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-kernel-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'extensional function-like methods'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-metaprog/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-metaprog') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Meta-programming features for mruby'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-test-inline-struct/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-test-inline-struct') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'inline structure'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-errno/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-errno') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = 'Internet Initiative Japan Inc.'
4 | spec.summary = 'Errno module and SystemCallError class'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-object-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-object-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'extensional methods shared by all objects'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-sleep/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-sleep') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = ['MATSUMOTO Ryosuke', 'mruby developers']
4 | spec.summary = 'Kernel#sleep and Kernel#usleep'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/test/t/basicobject.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # BasicObject
3 |
4 | assert('BasicObject') do
5 | assert_equal(Class, BasicObject.class)
6 | end
7 |
8 | assert('BasicObject superclass') do
9 | assert_nil(BasicObject.superclass)
10 | end
11 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/modules_optional:
--------------------------------------------------------------------------------
1 | buf
2 | complex_path
3 | complex_value
4 | conf_file
5 | encoding
6 | hash
7 | http
8 | path
9 | process
10 | regex
11 | rewrite
12 | set_var
13 | string
14 | upstream_list *
15 | uri
16 |
--------------------------------------------------------------------------------
/mrbgems/rack-based-api/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('rack-based-api') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = 'MATSUMOTO Ryosuke'
4 | spec.add_dependency('mruby-stringio', :github => 'ksss/mruby-stringio')
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-toplevel-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'toplevel object (main) methods extension'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | # Extend the tab with 8 whitespace
2 | 6fc5dc986a5ffc1a74c63ad0617ea1dcc10d3cdd
3 | # reformatted doc/opcode.md
4 | 61e8a540869c57ebddac53cf9d243db407d57fff
5 | # reindent parse.y
6 | 650ffb9d8410e1ae2206890ef6e2a8643c600454
7 |
--------------------------------------------------------------------------------
/mruby/mrbgems/full-core.gembox:
--------------------------------------------------------------------------------
1 | MRuby::GemBox.new do |conf|
2 | Dir.glob("#{root}/mrbgems/mruby-*/mrbgem.rake") do |x|
3 | g = File.basename(File.dirname(x))
4 | conf.gem :core => g unless g =~ /^mruby-(?:bin-debugger|test)$/
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-catch/mrblib/catch.rb:
--------------------------------------------------------------------------------
1 | class UncaughtThrowError < ArgumentError
2 | attr_reader :tag, :value
3 | def initialize(tag, value)
4 | @tag = tag
5 | @value = value
6 | super("uncaught throw #{tag.inspect}")
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/mruby/test/t/object.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # Object ISO Test
3 |
4 | assert('Object', '15.2.1') do
5 | assert_equal Class, Object.class
6 | end
7 |
8 | assert('Object superclass', '15.2.1.2') do
9 | assert_equal BasicObject, Object.superclass
10 | end
11 |
--------------------------------------------------------------------------------
/test/html/backtrace.rb:
--------------------------------------------------------------------------------
1 | class Foo
2 | def foo
3 | b = Bar.new
4 | b.bar
5 | end
6 | end
7 |
8 | class Bar
9 | def bar
10 | raise "Intentional Error for testing ngx_mrb_log_backtrace"
11 | end
12 | end
13 |
14 | Foo.new.foo
15 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb:
--------------------------------------------------------------------------------
1 | def self.include(*modules)
2 | self.class.include(*modules)
3 | end
4 |
5 | def self.private(*methods)
6 | end
7 | def self.protected(*methods)
8 | end
9 | def self.public(*methods)
10 | end
11 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-pack/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-pack') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = ['Internet Initiative Japan Inc.', 'mruby developers']
4 | spec.summary = 'Array#pack and String#unpack method'
5 | end
6 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_and_ruby_extension_example/test/example.rb:
--------------------------------------------------------------------------------
1 | assert('C and Ruby Extension Example 1') do
2 | CRubyExtension.respond_to? :c_method
3 | end
4 |
5 | assert('C and Ruby Extension Example 2') do
6 | CRubyExtension.respond_to? :ruby_method
7 | end
8 |
--------------------------------------------------------------------------------
/test/html/filter_dynamic_arg.rb:
--------------------------------------------------------------------------------
1 | r = Nginx::Request.new
2 | f = Nginx::Filter.new
3 | args = r.var.args
4 | if args.nil?
5 | f.body = "output filter: static"
6 | else
7 | r.headers_out["X-New-Header"] = args.to_s
8 | f.body = "output filter: #{args}"
9 | end
10 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/examples/http/set_var/config:
--------------------------------------------------------------------------------
1 | ngx_addon_name=ngx_http_set_var_examples_module
2 | HTTP_MODULES="$HTTP_MODULES ngx_http_set_var_examples_module"
3 | NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_set_var_examples_module.c"
4 | have=NDK_SET_VAR . auto/have
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-enumerator/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-enumerator') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.add_dependency('mruby-fiber', :core => 'mruby-fiber')
5 | spec.summary = 'Enumerator class'
6 | end
7 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/conf_args:
--------------------------------------------------------------------------------
1 |
2 | TAKE1
3 | TAKE2
4 | TAKE3
5 | TAKE4
6 | TAKE5
7 | TAKE6
8 | TAKE7
9 | TAKE8
10 | TAKE12
11 | TAKE13
12 | TAKE23
13 | TAKE123
14 | TAKE1234
15 | 1MORE
16 | 2MORE
17 | ANY
18 | FLAG
19 | BLOCK
20 | MULTI
21 | ARGS_NUMBER
22 |
23 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-hash-ext/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-hash-ext') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Hash class extension'
5 | spec.add_dependency 'mruby-array-ext', core: 'mruby-array-ext'
6 | end
7 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_encoding.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include
4 |
5 | typedef struct {
6 | char *from;
7 | char *to;
8 | } ndk_encoding_t;
9 |
10 |
11 | char * ndk_conf_set_encoding_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
12 |
13 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-rational/mrblib/rational.rb:
--------------------------------------------------------------------------------
1 | class Rational < Numeric
2 | def inspect
3 | "(#{to_s})"
4 | end
5 |
6 | def to_s
7 | "#{numerator}/#{denominator}"
8 | end
9 | end
10 |
11 | class Numeric
12 | def to_r
13 | Rational(self, 1)
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_process.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | typedef struct {
4 | int signo;
5 | char *signame;
6 | char *name;
7 | void (*handler)(int signo);
8 | } ngx_signal_t;
9 |
10 |
11 | ngx_int_t ndk_init_signals (ngx_signal_t *sig, ngx_log_t *log);
12 |
13 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-enum-chain/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-enum-chain') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Enumerator::Chain class'
5 | spec.add_dependency('mruby-enumerator', :core => 'mruby-enumerator')
6 | end
7 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-io/mrblib/file_constants.rb:
--------------------------------------------------------------------------------
1 | class File
2 | module Constants
3 | FNM_SYSCASE = 0
4 | FNM_NOESCAPE = 1
5 | FNM_PATHNAME = 2
6 | FNM_DOTMATCH = 4
7 | FNM_CASEFOLD = 8
8 | end
9 | end
10 |
11 | class File
12 | include File::Constants
13 | end
14 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-method/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-method') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Method and UnboundMethod class'
5 |
6 | spec.add_dependency('mruby-proc-ext', :core => 'mruby-proc-ext')
7 | end
8 |
--------------------------------------------------------------------------------
/mruby/build_config/mrbc.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
3 | conf.toolchain :visualcpp
4 | else
5 | conf.toolchain :gcc
6 | end
7 |
8 | conf.build_mrbc_exec
9 | conf.disable_libmruby
10 | conf.disable_presym
11 | end
12 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-set/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-set') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = 'yui-knk'
4 |
5 | spec.add_dependency "mruby-hash-ext", :core => "mruby-hash-ext"
6 | spec.add_dependency "mruby-enumerator", :core => "mruby-enumerator"
7 | end
8 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/contexts:
--------------------------------------------------------------------------------
1 |
2 | MAIN
3 | SRV
4 | SIF
5 | LOC
6 | LIF
7 |
8 | MAIN_SRV
9 | MAIN_SIF
10 | MAIN_LOC
11 | MAIN_LIF
12 | SRV_LOC
13 | SRV_LIF
14 | SIF_LOC
15 | SIF_LIF
16 |
17 | MAIN_SRV_LOC
18 | MAIN_SRV_LIF
19 | MAIN_SIF_LOC
20 | MAIN_SIF_LIF
21 | ANY_MAIN
22 |
23 |
--------------------------------------------------------------------------------
/example/proxy.rb:
--------------------------------------------------------------------------------
1 | # location /proxy {
2 | # mruby_set $backend "/path/to/proxy.rb";
3 | # proxy_pass http://$backend;
4 | # }
5 |
6 | backends = [
7 | "test1",
8 | "test2",
9 | "test3",
10 | ]
11 |
12 | r = Redis.new "192.168.12.251", 6379
13 | r.get backends[rand(backends.length)]
14 |
--------------------------------------------------------------------------------
/test/html/proxy.rb:
--------------------------------------------------------------------------------
1 | # location /proxy {
2 | # mruby_set $backend "/path/to/proxy.rb";
3 | # proxy_pass http://$backend;
4 | # }
5 |
6 | backends = [
7 | "test1",
8 | "test2",
9 | "test3",
10 | ]
11 |
12 | r = Redis.new "192.168.12.251", 6379
13 | r.get backends[rand(backends.length)]
14 |
--------------------------------------------------------------------------------
/mruby/include/mruby/re.h:
--------------------------------------------------------------------------------
1 | /**
2 | ** @file mruby/re.h - Regexp class
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #ifndef MRUBY_RE_H
8 | #define MRUBY_RE_H
9 |
10 | MRB_BEGIN_DECL
11 |
12 | #define REGEXP_CLASS "Regexp"
13 |
14 | MRB_END_DECL
15 |
16 | #endif /* RE_H */
17 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-binding/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-binding') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Binding class (core features only)'
5 |
6 | spec.add_test_dependency('mruby-proc-ext', :core => 'mruby-proc-ext')
7 | end
8 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-complex/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-complex') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Complex class'
5 | spec.build.defines << "MRB_USE_COMPLEX"
6 | spec.add_dependency 'mruby-math', core: 'mruby-math'
7 | end
8 |
--------------------------------------------------------------------------------
/mruby/build_config/host-cxx.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | conf.toolchain
3 |
4 | # include the default GEMs
5 | conf.gembox 'default'
6 |
7 | # C compiler settings
8 | conf.cc.defines = %w(MRB_USE_DEBUG_HOOK)
9 | conf.enable_debug
10 | conf.enable_cxx_abi
11 | conf.enable_test
12 | end
13 |
--------------------------------------------------------------------------------
/mruby/build_config/bench.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new('bench') do |conf|
2 | # Gets set by the VS command prompts.
3 | if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
4 | toolchain :visualcpp
5 | else
6 | toolchain :gcc
7 | conf.cc.flags << '-O3'
8 | end
9 |
10 | conf.gembox 'default'
11 | end
12 |
--------------------------------------------------------------------------------
/mruby/.github/linters/.yaml-lint.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # https://yamllint.readthedocs.io/en/stable/
3 | # yamllint --strict -c .github/linters/.yaml-lint.yml .
4 | extends: default
5 |
6 | rules:
7 | comments:
8 | min-spaces-from-content: 1
9 | document-start: disable
10 | line-length: disable
11 | truthy: false
12 |
--------------------------------------------------------------------------------
/mruby/build_config/android_arm64_v8a.rb:
--------------------------------------------------------------------------------
1 | # Requires Android NDK r13 or later.
2 | MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
3 | params = {
4 | :arch => 'arm64-v8a',
5 | :sdk_version => 33,
6 | :toolchain => :clang
7 | }
8 | toolchain :android, params
9 |
10 | conf.gembox 'default'
11 | end
12 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-rational/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-rational') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Rational class'
5 | spec.build.defines << "MRB_USE_RATIONAL"
6 | spec.add_test_dependency('mruby-complex', :core => 'mruby-complex')
7 | end
8 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.h:
--------------------------------------------------------------------------------
1 | /*
2 | * apiprint.h
3 | */
4 |
5 | #ifndef APIPRINT_H_
6 | #define APIPRINT_H_
7 |
8 | #include
9 | #include "mrdb.h"
10 |
11 | mrb_value mrb_debug_eval(mrb_state*, mrb_debug_context*, const char*, size_t, mrb_bool*, int);
12 |
13 | #endif /* APIPRINT_H_ */
14 |
--------------------------------------------------------------------------------
/mruby/build_config/clang-asan.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | conf.toolchain :clang
3 | # include the GEM box
4 | conf.gembox 'full-core'
5 |
6 | # Turn on `enable_debug` for better debugging
7 | conf.enable_sanitizer "address,undefined"
8 | conf.enable_debug
9 | conf.enable_bintest
10 | conf.enable_test
11 | end
12 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-strip/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-bin-strip') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'irep dump debug section remover command'
5 | spec.add_dependency 'mruby-compiler', :core => 'mruby-compiler'
6 | spec.bins = %w(mruby-strip)
7 | end
8 |
--------------------------------------------------------------------------------
/mruby/tasks/toolchains/clang.rake:
--------------------------------------------------------------------------------
1 | MRuby::Toolchain.new(:clang) do |conf, _params|
2 | toolchain :gcc, default_command: 'clang'
3 |
4 | [conf.cc, conf.objc, conf.asm].each do |cc|
5 | cc.flags << '-Wzero-length-array' unless ENV['CFLAGS']
6 | end
7 | conf.cxx.flags << '-Wzero-length-array' unless ENV['CXXFLAGS'] || ENV['CFLAGS']
8 | end
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | GPATH
2 | GRTAGS
3 | GTAGS
4 | GSYMS
5 | mrbgems_config
6 | mrbgems_config_dynamic
7 | Makefile
8 | config
9 | config.status
10 | config.log
11 | tags
12 | *.swp
13 | *~
14 | build/
15 | build_dynamic/
16 | autom4te.cache/
17 | .openssl_build_done
18 | .openssl_configure_done
19 | .mruby_version
20 | .vagrant/
21 | build_config.rb.lock
22 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-enum-lazy/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-enum-lazy') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Enumerator::Lazy class'
5 | spec.add_dependency('mruby-enumerator', :core => 'mruby-enumerator')
6 | spec.add_dependency('mruby-enum-ext', :core => 'mruby-enum-ext')
7 | end
8 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/examples/README:
--------------------------------------------------------------------------------
1 |
2 | 2010 (C) Marcus Clyne
3 |
4 |
5 | Examples
6 | --------
7 |
8 | In this section there are a number of examples of the various features of the tools
9 | module. These have been given in the form of dummy modules, to make it easier to
10 | use as templates for your own module should you choose to do so.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/mruby/.github/linters/.ecrc:
--------------------------------------------------------------------------------
1 | {
2 | "verbose": false,
3 | "ignore_defaults": false,
4 | "exclude": ["oss-fuzz/", "src/"],
5 | "disable": {
6 | "end_of_line": false,
7 | "trim_trailing_whitespace": false,
8 | "insert_final_newline": false,
9 | "indent_size": true,
10 | "indent_style": true
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/mruby/build_config/host-gprof.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | # load specific toolchain settings
3 | toolchain :gcc
4 |
5 | # include the GEM box
6 | conf.gembox 'full-core'
7 |
8 | conf.cc.flags << '-pg'
9 | conf.linker.flags << '-pg'
10 |
11 | # Turn on `enable_debug` for better debugging
12 | conf.enable_debug
13 | conf.enable_test
14 | end
15 |
--------------------------------------------------------------------------------
/mruby/build_config/host-f32.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | # load specific toolchain settings
3 | toolchain :gcc
4 |
5 | # include the GEM box
6 | conf.gembox 'full-core'
7 |
8 | conf.cc.defines << 'MRB_USE_FLOAT32'
9 |
10 | # Turn on `enable_debug` for better debugging
11 | conf.enable_debug
12 | conf.enable_test
13 | conf.enable_bintest
14 | end
15 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-bin-debugger') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'mruby debugger command'
5 | spec.build.defines << "MRB_USE_DEBUG_HOOK"
6 | spec.add_dependency('mruby-eval', :core => 'mruby-eval')
7 |
8 | spec.bins = %w(mrdb)
9 | end
10 |
--------------------------------------------------------------------------------
/mrbgems/auto-ssl/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('auto-ssl') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = 'MATSUMOTO Ryosuke'
4 | spec.add_dependency('mruby-io', :github => 'iij/mruby-io')
5 | spec.add_dependency('mruby-acme-client', :github => 'pyama86/mruby-acme-client')
6 | spec.add_dependency('mruby-sleep', :github => 'matsumotory/mruby-sleep')
7 | end
8 |
--------------------------------------------------------------------------------
/mruby/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | test:
4 | build:
5 | context: .
6 | command: sh -c 'rake deep_clean && rake -m test:build && rake test:run'
7 | environment:
8 | - MRUBY_CONFIG=ci/gcc-clang
9 | - CC=gcc
10 | - CXX=g++
11 | - LD=gcc
12 | - SKIP=check-executables-have-shebangs
13 | working_dir: /app
14 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/src/palloc.h:
--------------------------------------------------------------------------------
1 |
2 | #define %2%_pallocp(p,pl) p = %1%_palloc (pl,sizeof(*p))
3 | #define %2%_pallocpn(p,pl,n) p = %1%_palloc (pl,sizeof(*p)*(n))
4 |
5 | #define %2%_pcallocp(p,pl) p = %1%_pcalloc (pl,sizeof(*p))
6 | #define %2%_pcallocpn(p,pl,n) p = %1%_pcalloc (pl,sizeof(*p)*(n))
7 |
--------------------------------------------------------------------------------
/mruby/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Basic set up
2 | version: 2
3 | updates:
4 | # Maintain dependencies for Ruby
5 | - package-ecosystem: "bundler"
6 | directory: "/"
7 | schedule:
8 | interval: "daily"
9 | # Maintain dependencies for GitHub Actions
10 | - package-ecosystem: "github-actions"
11 | directory: "/"
12 | schedule:
13 | interval: "daily"
14 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-cmath/mrbgem.rake:
--------------------------------------------------------------------------------
1 | # This `mruby-cmath` gem uses C99 _Complex features
2 | # You need C compiler that support C99+
3 | MRuby::Gem::Specification.new('mruby-cmath') do |spec|
4 | spec.license = 'MIT'
5 | spec.author = 'mruby developers'
6 | spec.summary = 'standard Math module with complex'
7 | spec.add_dependency 'mruby-complex', :core => 'mruby-complex'
8 | end
9 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-io/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-io') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = ['Internet Initiative Japan Inc.', 'mruby developers']
4 | spec.summary = 'IO and File class'
5 |
6 | if spec.for_windows?
7 | spec.linker.libraries << "ws2_32"
8 | end
9 | spec.add_test_dependency 'mruby-time', core: 'mruby-time'
10 | end
11 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apistring.h:
--------------------------------------------------------------------------------
1 | /*
2 | * apistring.h
3 | */
4 |
5 | #ifndef APISTRING_H_
6 | #define APISTRING_H_
7 |
8 | #include "mruby.h"
9 |
10 | /* both functions return a null pointer on failure */
11 | char *mrdb_strndup(mrb_state *mrb, const char *s, size_t size);
12 | char *mrdb_strdup(mrb_state *mrb, const char *s);
13 |
14 | #endif /* APISTRING_H_ */
15 |
--------------------------------------------------------------------------------
/mruby/TODO.md:
--------------------------------------------------------------------------------
1 | # Things to Do in the future
2 |
3 | # After mruby 3.1
4 |
5 | - parser and code generator independent from `mrb_state` (picoruby?)
6 | - variable sized AST node
7 | - iv/hash entry cache
8 | - more peephole optimization (if possible)
9 |
10 | # Things to do (Things we need to consider)
11 |
12 | - `begin ... end while cond` to behave as CRuby
13 | - special variables ($1,$2..)
14 |
--------------------------------------------------------------------------------
/mruby/build_config/host-m32.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | # load specific toolchain settings
3 | toolchain :gcc
4 |
5 | # include the GEM box
6 | conf.gembox 'full-core'
7 |
8 | conf.cc.flags << '-m32'
9 | conf.linker.flags << '-m32'
10 |
11 | # Turn on `enable_debug` for better debugging
12 | conf.enable_debug
13 | conf.enable_test
14 | conf.enable_bintest
15 | end
16 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.h:
--------------------------------------------------------------------------------
1 | /*
2 | * apilist.h
3 | */
4 |
5 | #ifndef APILIST_H_
6 | #define APILIST_H_
7 |
8 | #include
9 | #include "mrdb.h"
10 |
11 | int32_t mrb_debug_list(mrb_state*, mrb_debug_context*, char*, uint16_t, uint16_t);
12 | char* mrb_debug_get_source(mrb_state*, mrdb_state*, const char*, const char *);
13 |
14 | #endif /* APILIST_H_ */
15 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-object-ext/test/nil.rb:
--------------------------------------------------------------------------------
1 | assert('NilClass#to_a') do
2 | assert_equal [], nil.to_a
3 | end
4 |
5 | assert('NilClass#to_f') do
6 | skip unless Object.const_defined?(:Float)
7 | assert_equal 0.0, nil.to_f
8 | end
9 |
10 | assert('NilClass#to_h') do
11 | assert_equal Hash.new, nil.to_h
12 | end
13 |
14 | assert('NilClass#to_i') do
15 | assert_equal 0, nil.to_i
16 | end
17 |
--------------------------------------------------------------------------------
/mruby/test/t/localjumperror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # LocalJumpError ISO Test
3 |
4 | assert('LocalJumpError', '15.2.25') do
5 | assert_equal Class, LocalJumpError.class
6 | # assert_raise LocalJumpError do
7 | # # this will cause an exception due to the wrong location
8 | # retry
9 | # end
10 | end
11 |
12 | # TODO 15.2.25.2.1 LocalJumpError#exit_value
13 | # TODO 15.2.25.2.2 LocalJumpError#reason
14 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/text/autogen:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * 2010 (C) Marcus Clyne
4 | *
5 | * DO NOT EDIT THIS FILE MANUALLY
6 | * ------------------------------
7 | * This file has been generated automatically from scripts in the $base/auto dir and
8 | * data in the $base/auto/data dir. If you wish to edit the output of this file, then
9 | * you should edit these files instead.
10 | *
11 | */
12 |
13 |
--------------------------------------------------------------------------------
/mruby/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ruby:3.2.2-bullseye
2 |
3 | RUN apt-get update && apt-get install --no-install-recommends -y python3-pip shellcheck \
4 | && apt-get clean \
5 | && rm -rf /var/lib/apt/lists/*
6 |
7 | WORKDIR /app
8 |
9 | COPY Gemfile Gemfile.lock .pre-commit-config.yaml ./
10 |
11 | RUN bundle install && pip3 install pre-commit && git init . && pre-commit install-hooks
12 |
13 | COPY . .
14 |
--------------------------------------------------------------------------------
/mruby/build_config/android_armeabi_v7a_neon_hard.rb:
--------------------------------------------------------------------------------
1 | # Requires Android NDK r13 or later.
2 | MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
3 | params = {
4 | :arch => 'armeabi-v7a',
5 | :mfpu => 'neon',
6 | :mfloat_abi => 'hard',
7 | :sdk_version => 33,
8 | :toolchain => :clang
9 | }
10 | toolchain :android, params
11 |
12 | conf.gembox 'default'
13 | end
14 |
--------------------------------------------------------------------------------
/mruby/.yardopts:
--------------------------------------------------------------------------------
1 | --markup markdown
2 | --plugin mruby
3 | --plugin coderay
4 | --output-dir doc/api
5 |
6 | src/**/*.c
7 | mrblib/**/*.rb
8 | include/**/*.h
9 |
10 | mrbgems/*/src/**/*.c
11 | mrbgems/*/mrblib/**/*.rb
12 | mrbgems/*/include/**/*.h
13 | -
14 | CONTRIBUTING.md
15 | SECURITY.md
16 | TODO.md
17 | doc/*.md
18 | doc/guides/*.md
19 | doc/internal/*.md
20 | AUTHORS
21 | LEGAL
22 | LICENSE
23 | NEWS
24 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-errno/mrblib/errno.rb:
--------------------------------------------------------------------------------
1 | module Errno
2 | def Errno.const_defined?(name)
3 | __errno_defined?(name) or super
4 | end
5 |
6 | def Errno.const_missing(name)
7 | __errno_define(name) or super
8 | end
9 |
10 | # Module#constants is defined in mruby-metaprog
11 | # So, it may be raised NoMethodError
12 | def Errno.constants
13 | __errno_list(super)
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/mruby/tasks/core.rake:
--------------------------------------------------------------------------------
1 | as_cxx_srcs = %w[vm error gc].map{|name| "#{MRUBY_ROOT}/src/#{name}.c"}
2 |
3 | MRuby.each_target do
4 | objs = Dir.glob("#{MRUBY_ROOT}/src/*.c").map do |src|
5 | if cxx_exception_enabled? && as_cxx_srcs.include?(src)
6 | compile_as_cxx(src)
7 | else
8 | objfile(src.pathmap("#{build_dir}/src/%n"))
9 | end
10 | end
11 | self.libmruby_core_objs << objs
12 | end
13 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-proc-binding/test/proc-binding.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | static mrb_value
5 | proc_in_c(mrb_state *mrb, mrb_value self)
6 | {
7 | return mrb_load_string(mrb, "proc { |a, b| a + b }");
8 | }
9 |
10 | void
11 | mrb_mruby_proc_binding_gem_test(mrb_state *mrb)
12 | {
13 | mrb_define_method(mrb, mrb->object_class, "proc_in_c", proc_in_c, MRB_ARGS_NONE());
14 | }
15 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/action_types:
--------------------------------------------------------------------------------
1 | r0 return 0
2 | r1 return 1
3 | r_1 return -1
4 | rok return %OK%
5 | rce return %CE%
6 | rcok return %COK%
7 | re return %E%
8 | rn return NULL
9 | rse {ngx_script_error (e); return;}
10 | sce {ngx_script_configure_error (c); return;}
11 | g(_lb) goto _lb
12 | ge goto error
13 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-errno/src/gen.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | Dir.chdir(File.dirname($0))
4 |
5 | d = File.open("known_errors_def.cstub", "w")
6 |
7 | IO.readlines("known_errors.def").each { |name|
8 | next if name =~ /^#/
9 | name.strip!
10 |
11 | d.write <(*args, **opts, &block) { call(other.call(*args, **opts, &block)) }
11 | end
12 |
13 | def >>(other)
14 | ->(*args, **opts, &block) { other.call(call(*args, **opts, &block)) }
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/mruby/build_config/cross-32bit.rb:
--------------------------------------------------------------------------------
1 | # Define cross build settings
2 | MRuby::CrossBuild.new('cross-32bit') do |conf|
3 | conf.toolchain :gcc
4 |
5 | conf.cc.flags << "-m32"
6 | conf.linker.flags << "-m32"
7 |
8 | # conf.build_mrbtest_lib_only
9 |
10 | conf.gem :core => "mruby-bin-mruby"
11 | conf.gem "#{MRUBY_ROOT}/examples/mrbgems/c_and_ruby_extension_example"
12 |
13 | conf.test_runner.command = 'env'
14 | end
15 |
--------------------------------------------------------------------------------
/mruby/.github/workflows/labeler.yml:
--------------------------------------------------------------------------------
1 | # https://github.com/actions/labeler
2 | name: Pull Request Labeler
3 | on:
4 | - pull_request_target
5 | jobs:
6 | triage:
7 | permissions:
8 | contents: read
9 | pull-requests: write
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/labeler@v5
13 | with:
14 | repo-token: "${{ secrets.GITHUB_TOKEN }}"
15 | sync-labels: true
16 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/src/gen.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | Dir.chdir(File.dirname($0))
4 |
5 | f = File.open("const.cstub", "w")
6 |
7 | IO.readlines("const.def").each { |name|
8 | name.sub(/^#.*/, "")
9 | name.strip!
10 | next if name.empty?
11 |
12 | f.write < "mruby-metaprog"
6 |
7 | # Use Method/UnboundMethod class
8 | conf.gem :core => "mruby-method"
9 |
10 | # Use eval()
11 | conf.gem :core => "mruby-eval"
12 |
13 | # Use mruby-compiler to build other mrbgems
14 | conf.gem :core => "mruby-compiler"
15 | end
16 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-binding/test/binding.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | static mrb_value
5 | binding_in_c(mrb_state *mrb, mrb_value self)
6 | {
7 | return mrb_funcall_argv(mrb, mrb_obj_value(mrb->object_class), MRB_SYM(binding), 0, NULL);
8 | }
9 |
10 | void
11 | mrb_mruby_binding_gem_test(mrb_state *mrb)
12 | {
13 | mrb_define_method(mrb, mrb->object_class, "binding_in_c", binding_in_c, MRB_ARGS_NONE());
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_init.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_init.h - ngx_mruby mruby init header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_INIT_H
8 | #define NGX_HTTP_MRUBY_INIT_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | ngx_int_t ngx_mrb_class_init(mrb_state *mrb);
17 |
18 | #endif // NGX_HTTP_MRUBY_INIT_H
19 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/test/udpsocket.rb:
--------------------------------------------------------------------------------
1 | assert('UDPSocket.new') do
2 | s = UDPSocket.new
3 | assert_true(s.is_a? UDPSocket)
4 | s.close
5 | s = UDPSocket.new(Socket::AF_INET6)
6 | assert_true(s.is_a? UDPSocket)
7 | s.close
8 | true
9 | end
10 |
11 | #assert('UDPSocket#connect') do
12 | #assert('UDPSocket#send') do
13 | #assert('UDPSocket#recv') do
14 |
15 | #assert('UDPSocket#bind') do
16 | #assert('UDPSocket#recvfrom_nonblock') do
17 |
--------------------------------------------------------------------------------
/mruby/mrbgems/math.gembox:
--------------------------------------------------------------------------------
1 | # It also works with MRB_NO_STDIO.
2 |
3 | MRuby::GemBox.new do |conf|
4 | # Use standard Math module
5 | conf.gem :core => "mruby-math"
6 |
7 | # Use Rational/Complex numbers
8 | conf.gem :core => "mruby-rational"
9 | conf.gem :core => "mruby-complex"
10 | # Use Complex math functions in CMath module
11 | conf.gem :core => "mruby-cmath"
12 | # Use Multi-precision Integer
13 | conf.gem :core => "mruby-bigint"
14 | end
15 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bigint/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-bigint') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Integer class extension to multiple-precision'
5 | spec.build.defines << "MRB_USE_BIGINT"
6 |
7 | spec.build.libmruby_core_objs << Dir.glob(File.join(__dir__, "core/**/*.c")).map { |fn|
8 | objfile(fn.relative_path_from(__dir__).pathmap("#{spec.build_dir}/%X"))
9 | }
10 | end
11 |
--------------------------------------------------------------------------------
/src/stream/ngx_stream_mruby_init.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_stream_mruby_init.h - ngx_mruby mruby init header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_STREAM_MRUBY_INIT_H
8 | #define NGX_STREAM_MRUBY_INIT_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | ngx_int_t ngx_stream_mrb_class_init(mrb_state *mrb);
17 |
18 | #endif // NGX_STREAM_MRUBY_INIT_H
19 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-io/src/mruby_io_gem.c:
--------------------------------------------------------------------------------
1 | #include "mruby.h"
2 |
3 | void mrb_init_io(mrb_state *mrb);
4 | void mrb_init_file(mrb_state *mrb);
5 | void mrb_init_file_test(mrb_state *mrb);
6 |
7 | #define DONE mrb_gc_arena_restore(mrb, 0)
8 |
9 | void
10 | mrb_mruby_io_gem_init(mrb_state* mrb)
11 | {
12 | mrb_init_io(mrb); DONE;
13 | mrb_init_file(mrb); DONE;
14 | mrb_init_file_test(mrb); DONE;
15 | }
16 |
17 | void
18 | mrb_mruby_io_gem_final(mrb_state* mrb)
19 | {
20 | }
21 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_filter.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_filter.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_FILTER_H
8 | #define NGX_HTTP_MRUBY_FILTER_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | void ngx_mrb_filter_class_init(mrb_state *mrb, struct RClass *class);
17 |
18 | #endif // NGX_HTTP_MRUBY_FILTER_H
19 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_server.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_server.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_SERVER_H
8 | #define NGX_HTTP_MRUBY_SERVER_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | void ngx_mrb_server_class_init(mrb_state *mrb, struct RClass *class);
17 |
18 | #endif // NGX_HTTP_MRUBY_SERVER_H
19 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-eval/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-eval') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'standard Kernel#eval method'
5 |
6 | add_dependency 'mruby-compiler', :core => 'mruby-compiler'
7 | add_dependency 'mruby-binding', :core => 'mruby-binding'
8 | spec.add_test_dependency('mruby-metaprog', :core => 'mruby-metaprog')
9 | spec.add_test_dependency('mruby-method', :core => 'mruby-method')
10 | end
11 |
--------------------------------------------------------------------------------
/mruby/oss-fuzz/mruby_fuzzer.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | int LLVMFuzzerTestOneInput(uint8_t *Data, size_t size) {
7 | if (size < 1) {
8 | return 0;
9 | }
10 | char *code = malloc(size+1);
11 | memcpy(code, Data, size);
12 | code[size] = '\0';
13 | mrb_state *mrb = mrb_open();
14 | mrb_load_string(mrb, code);
15 | mrb_close(mrb);
16 | free(code);
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-bin-mruby') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'mruby command'
5 | spec.bins = %w(mruby)
6 | spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
7 | spec.add_test_dependency('mruby-print', :core => 'mruby-print')
8 |
9 | if build.cxx_exception_enabled?
10 | build.compile_as_cxx("#{spec.dir}/tools/mruby/mruby.c")
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Mac",
5 | "includePath": [
6 | "${workspaceFolder}/**"
7 | ],
8 | "defines": [],
9 | "macFrameworkPath": [],
10 | "compilerPath": "/usr/local/bin/gcc-8",
11 | "cStandard": "gnu18",
12 | "cppStandard": "gnu++14",
13 | "intelliSenseMode": "gcc-x64"
14 | }
15 | ],
16 | "version": 4
17 | }
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_connection.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_connection.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_CONNECTION_H
8 | #define NGX_HTTP_MRUBY_CONNECTION_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | void ngx_mrb_conn_class_init(mrb_state *mrb, struct RClass *class);
17 |
18 | #endif // NGX_HTTP_MRUBY_CONNECTION_H
19 |
--------------------------------------------------------------------------------
/mruby/.gitignore:
--------------------------------------------------------------------------------
1 | *.bak
2 | *.bc
3 | *.d
4 | *.i
5 | *.lock
6 | *.o
7 | *.orig
8 | *.pdb
9 | *.rej
10 | *.s
11 | *.sav
12 | *.swp
13 | *.tmp
14 | *~
15 | .DS_Store
16 | .ccls*
17 | .ccmalloc
18 | .svn
19 | .vscode
20 | .yardoc
21 | /.git
22 | /benchmark/**/*.dat
23 | /benchmark/*.pdf
24 | /benchmark/*.png
25 | /bin
26 | /build
27 | /doc/api
28 | /doc/capi
29 | /mruby-source-*.gem
30 | compile_commands.json
31 | compile_flags.txt
32 | cscope.files
33 | cscope.out
34 | node_modules
35 | tags
36 | !Gemfile.lock
37 |
--------------------------------------------------------------------------------
/mruby/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | coderay (1.1.3)
5 | rake (13.0.6)
6 | webrick (1.7.0)
7 | yard (0.9.28)
8 | webrick (~> 1.7.0)
9 | yard-coderay (0.1.0)
10 | coderay
11 | yard
12 | yard-mruby (0.3.0)
13 | yard (~> 0.9.0)
14 |
15 | PLATFORMS
16 | ruby
17 | x86_64-darwin-21
18 | x86_64-linux
19 |
20 | DEPENDENCIES
21 | rake
22 | yard
23 | yard-coderay
24 | yard-mruby
25 |
26 | BUNDLED WITH
27 | 2.4.10
28 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-proc-binding/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-proc-binding') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'Proc#binding method'
5 |
6 | spec.add_dependency('mruby-binding', :core => 'mruby-binding')
7 | spec.add_dependency('mruby-proc-ext', :core => 'mruby-proc-ext')
8 | spec.add_test_dependency('mruby-eval', :core => 'mruby-eval')
9 | spec.add_test_dependency('mruby-compiler', :core => 'mruby-compiler')
10 | end
11 |
--------------------------------------------------------------------------------
/test/t/issue-268-test.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require 'socket'
4 |
5 | request_body = %({"hello": "ngx_mruby"})
6 | headers = < "mruby-io"
6 |
7 | # Use standard IO/File class
8 | conf.gem :core => "mruby-socket"
9 |
10 | # Use standard print/puts/p
11 | conf.gem :core => "mruby-print"
12 |
13 | # Use errno extension for a good mruby-io/mruby-socket experience
14 | conf.gem :core => "mruby-errno"
15 |
16 | # Use Dir class
17 | conf.gem :core => "mruby-dir"
18 | end
19 |
--------------------------------------------------------------------------------
/src/stream/ngx_stream_mruby_connection.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_stream_mruby_connection.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_STREAM_MRUBY_CONNECTION_H
8 | #define NGX_STREAM_MRUBY_CONNECTION_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | void ngx_stream_mrb_conn_class_init(mrb_state *mrb, struct RClass *class);
17 |
18 | #endif // NGX_STREAM_MRUBY_CONNECTION_H
19 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-os-memsize/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-os-memsize') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'ObjectSpace memsize_of method'
5 |
6 | spec.add_dependency('mruby-objectspace', :core => 'mruby-objectspace')
7 | spec.add_test_dependency('mruby-metaprog', :core => 'mruby-metaprog')
8 | spec.add_test_dependency('mruby-method', :core => 'mruby-method')
9 | spec.add_test_dependency('mruby-fiber', :core => 'mruby-fiber')
10 | end
11 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-sleep/README.md:
--------------------------------------------------------------------------------
1 | # Sleep Module for mruby
2 |
3 | mruby sleep module
4 |
5 | ## Install by mrbgems
6 |
7 | - add `conf.gem` line to your build configuration.
8 |
9 | ```ruby
10 | MRuby::Build.new do |conf|
11 |
12 | # ... (snip) ...
13 |
14 | conf.gem :core => 'mruby-sleep'
15 | end
16 | ```
17 |
18 | ## Example
19 |
20 | ```ruby
21 | sleep(10)
22 | usleep(10000)
23 | ```
24 |
25 | # License
26 |
27 | under the MIT License:
28 |
29 | -
30 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_ssl.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_ssl.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_SSL_H
8 | #define NGX_HTTP_MRUBY_SSL_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #if (NGX_HTTP_SSL)
15 |
16 | #include
17 |
18 | void ngx_mrb_ssl_class_init(mrb_state *mrb, struct RClass *class);
19 |
20 | #endif // NGX_HTTP_SSL
21 |
22 | #endif // NGX_HTTP_MRUBY_SSL_H
23 |
--------------------------------------------------------------------------------
/mruby/build_config/host-debug.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new('host') do |conf|
2 | # load specific toolchain settings
3 | conf.toolchain
4 |
5 | conf.enable_debug
6 |
7 | # include the default GEMs
8 | conf.gembox 'full-core'
9 |
10 | # C compiler settings
11 | conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING MRB_UTF8_STRING)
12 |
13 | # Generate mruby debugger command (require mruby-eval)
14 | conf.gem :core => "mruby-bin-debugger"
15 |
16 | # test
17 | conf.enable_test
18 | # bintest
19 | conf.enable_bintest
20 | end
21 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/actions/palloc:
--------------------------------------------------------------------------------
1 |
2 | palloc (p,pl,sz) p = %1%_palloc (pl,sz); if (p == NULL) %A%
3 | pallocp (p,pl) %2%_pallocp (p,pl); if (p == NULL) %A%
4 | pallocpn (p,pl,n) %2%_pallocpn (p,pl,n); if (p == NULL) %A%
5 | pcalloc (p,pl,sz) p = %1%_pcalloc (pl,sz); if (p == NULL) %A%
6 | pcallocp (p,pl) %2%_pcallocp (p,pl); if (p == NULL) %A%
7 | pcallocpn (p,pl,n) %2%_pcallocpn (p,pl,n); if (p == NULL) %A%
8 |
9 |
--------------------------------------------------------------------------------
/mruby/build_config/cross-mingw.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Ubuntu 20.04 requires at least `gcc-mingw-w64-x86-64` package as a
3 | # cross compiler.
4 | #
5 |
6 | MRuby::CrossBuild.new("cross-mingw") do |conf|
7 | conf.toolchain :gcc
8 | conf.host_target = "x86_64-w64-mingw32" # required for `for_windows?` used by `mruby-socket` gem
9 | conf.cc.command = "#{conf.host_target}-gcc-posix"
10 | conf.linker.command = conf.cc.command
11 | conf.archiver.command = "#{conf.host_target}-gcc-ar"
12 | conf.exts.executable = ".exe"
13 | conf.gembox "default"
14 | end
15 |
--------------------------------------------------------------------------------
/mruby/build_config/host-nofloat.rb:
--------------------------------------------------------------------------------
1 | MRuby::Build.new do |conf|
2 | # load specific toolchain settings
3 | toolchain :gcc
4 |
5 | # include the GEM box
6 | conf.gembox "stdlib"
7 | conf.gembox "stdlib-ext"
8 | conf.gembox "stdlib-io"
9 | conf.gembox "metaprog"
10 |
11 | conf.gem :core => 'mruby-bin-mruby'
12 | conf.gem :core => 'mruby-bin-mirb'
13 |
14 | # Add configuration
15 | conf.compilers.each do |c|
16 | c.defines << "MRB_NO_FLOAT"
17 | end
18 |
19 | conf.enable_debug
20 | conf.enable_test
21 | conf.enable_bintest
22 | end
23 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/src/array.h:
--------------------------------------------------------------------------------
1 |
2 | #define %2%_array_count(a) ((a)->nelts)
3 | #define %2%_array_get_first(a) ((a)->elts)
4 | #define %2%_array_get_index(a,n) ((void*) ((char*) (a)->elts + (a)->size * n))
5 | #define %2%_array_get_last(a) ((void*) ((char*) (a)->elts + (a)->size * ((a)->nelts - 1)))
6 | #define %2%_array_get_reverse_index(a,n) ((void*) ((char*) (a)->elts + (a)->size * ((a)->nelts - 1 - n)))
7 | #define %2%_array_push_clean(p,a) {p = %1%_array_push (a); %2%_zerop (p);}
8 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/test/basicsocket.rb:
--------------------------------------------------------------------------------
1 | assert('BasicSocket') do
2 | assert_equal(Class, BasicSocket.class)
3 | end
4 |
5 | assert('super class of BasicSocket') do
6 | assert_equal(IO, BasicSocket.superclass)
7 | end
8 |
9 | assert('BasicSocket.do_not_reverse_lookup') do
10 | assert_equal(BasicSocket.do_not_reverse_lookup, true)
11 | end
12 |
13 | assert('BasicSocket.do_not_reverse_lookup=') do
14 | BasicSocket.do_not_reverse_lookup = false
15 | assert_equal(BasicSocket.do_not_reverse_lookup, false)
16 | BasicSocket.do_not_reverse_lookup = true
17 | end
18 |
--------------------------------------------------------------------------------
/mruby/src/value_array.h:
--------------------------------------------------------------------------------
1 | #ifndef MRB_VALUE_ARRAY_H__
2 | #define MRB_VALUE_ARRAY_H__
3 |
4 | #include
5 |
6 | static inline void
7 | value_move(mrb_value *s1, const mrb_value *s2, size_t n)
8 | {
9 | if (n == 0) return;
10 | if (s1 > s2 && s1 < s2 + n)
11 | {
12 | s1 += n;
13 | s2 += n;
14 | while (n-- > 0) {
15 | *--s1 = *--s2;
16 | }
17 | }
18 | else if (s1 != s2) {
19 | while (n-- > 0) {
20 | *s1++ = *s2++;
21 | }
22 | }
23 | else {
24 | /* nothing to do. */
25 | }
26 | }
27 |
28 | #endif /* MRB_VALUE_ARRAY_H__ */
29 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | @matsumotory Please review.
2 |
3 | ## Pull-Request Check List
4 |
5 | - [ ] Add patches into `src/`.
6 | - [ ] Add test into `test/`. Please see about [test docs](https://github.com/matsumotory/ngx_mruby/tree/master/docs/test).
7 | - [ ] Add docs into `docs/` if you change the features such as [build system](https://github.com/matsumotory/ngx_mruby/tree/master/docs/install), [Ruby methods, class](https://github.com/matsumotory/ngx_mruby/tree/master/docs/class_and_method) and [nginx directives](https://github.com/matsumotory/ngx_mruby/tree/master/docs/directives).
8 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdberror.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** mrdberror.h - mruby debugger error code
3 | **
4 | */
5 |
6 | #ifndef MRDBERROR_H
7 | #define MRDBERROR_H
8 |
9 | #define MRB_DEBUG_OK (0)
10 | #define MRB_DEBUG_NOBUF (-1)
11 | #define MRB_DEBUG_INVALID_ARGUMENT (-2)
12 |
13 | #define MRB_DEBUG_BREAK_INVALID_LINENO (-11)
14 | #define MRB_DEBUG_BREAK_INVALID_FILE (-12)
15 | #define MRB_DEBUG_BREAK_INVALID_NO (-13)
16 | #define MRB_DEBUG_BREAK_NUM_OVER (-14)
17 | #define MRB_DEBUG_BREAK_NO_OVER (-15)
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_var.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_var.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_var.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_VAR_H
8 | #define NGX_HTTP_MRUBY_VAR_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | mrb_value ngx_mrb_var_set_vector(mrb_state *mrb, mrb_value self, char *k, int len, mrb_value o, ngx_http_request_t *r);
17 |
18 | void ngx_mrb_var_class_init(mrb_state *mrb, struct RClass *class);
19 |
20 | #endif // NGX_HTTP_MRUBY_VAR_H
21 |
--------------------------------------------------------------------------------
/mruby/build_config/boxing.rb:
--------------------------------------------------------------------------------
1 | boxings = %w[no word nan]
2 | bits = [64, 32]
3 | ints = [64, 32]
4 |
5 | boxings.product(bits, ints) do |boxing, bit, int|
6 | MRuby::Build.new("boxing-#{boxing}-m#{bit}-i#{int}") do |conf|
7 | conf.toolchain :gcc
8 | conf.gembox 'full-core'
9 | conf.compilers.each do |c|
10 | c.defines << "MRB_#{boxing.upcase}_BOXING"
11 | c.defines << "MRB_INT#{int}"
12 | c.flags << "-m#{bit}"
13 | end
14 | conf.linker.flags << "-m#{bit}"
15 | conf.enable_debug
16 | conf.enable_test
17 | conf.enable_bintest
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/mruby/test/t/nomethoderror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # NoMethodError ISO Test
3 |
4 | assert('NoMethodError', '15.2.32') do
5 | NoMethodError.class == Class
6 | assert_raise NoMethodError do
7 | doesNotExistAsAMethodNameForVerySure("")
8 | end
9 | end
10 |
11 | assert('NoMethodError#args', '15.2.32.2.1') do
12 | a = NoMethodError.new 'test', :test, [1, 2]
13 | assert_equal [1, 2], a.args
14 |
15 | assert_nothing_raised do
16 | begin
17 | doesNotExistAsAMethodNameForVerySure 3, 1, 4
18 | rescue NoMethodError => e
19 | assert_equal [3, 1, 4], e.args
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_process.c:
--------------------------------------------------------------------------------
1 |
2 | ngx_int_t
3 | ndk_init_signals (ngx_signal_t *sig, ngx_log_t *log)
4 | {
5 | struct sigaction sa;
6 |
7 | for ( ; sig->signo != 0; sig++) {
8 | ndk_zerov (sa);
9 | sa.sa_handler = sig->handler;
10 | sigemptyset (&sa.sa_mask);
11 |
12 | if (sigaction (sig->signo, &sa, NULL) == -1) {
13 | ngx_log_error (NGX_LOG_EMERG, log, ngx_errno,
14 | "sigaction(%s) failed", sig->signame);
15 | return NGX_ERROR;
16 | }
17 | }
18 |
19 | return NGX_OK;
20 | }
21 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bigint/README.md:
--------------------------------------------------------------------------------
1 | # Multi-precision Integer extension for mruby
2 |
3 | This extension uses fgmp, which is a public domain implementation of a subset of the GNU gmp library by Mark Henderson .
4 | But it's heavily modified to fit with mruby. You can get the original source code from .
5 | You can read the original README for fgmp in [README-fgmp.md](README-fgmp.md).
6 |
7 | If you want to create your own Multi-precision Integer GEM, see [examples/mrbgems/mruby-YOUR-bigint/TODO-HINT.md](../../examples/mrbgems/mruby-YOUR-bigint/TODO-HINT.md).
8 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/actions/array:
--------------------------------------------------------------------------------
1 |
2 | array_create (a,pl,n,sz) a = %1%_array_create (pl,n,sz); if (a == NULL) %A%
3 | array_init (a,pl,n,sz) if (%1%_array_init (a,pl,n,sz) == %E%) %A%
4 | array_push (p,a) p = %1%_array_push (a); if (p == NULL) %A%
5 | array_push_clean (p,a) p = %1%_array_push (a); if (p == NULL) %A%; %2%_zerop (p)
6 | array_push_n (p,a,n) p = %1%_array_push_n (a,n); if (p == NULL) %A%
7 | array_push_n_clean (p,a,n) p = %1%_array_push_n (a,n); if (p == NULL) %A%; %2%_zeropn (p,n)
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-set/README.md:
--------------------------------------------------------------------------------
1 | # mruby-set
2 |
3 | Set class
4 |
5 | ## Example
6 |
7 | ```ruby
8 | set1 = Set.new([1,2])
9 | set2 = Set[1,2,3]
10 | set3 = Set[4]
11 |
12 | set1 + set3
13 | #=> #
14 | set2 - set1
15 | #=> #
16 | set2 & set1
17 | #=> #
18 | set1 ^ set2
19 | #=> #
20 | ```
21 |
22 | ## Limitations
23 |
24 | These methods are not implemented yet:
25 |
26 | - freeze
27 | - to_set
28 | - divide(Set#divide with 2 arity block is not implemented.)
29 |
30 | ## License
31 |
32 | Under the MIT License:
33 |
34 | - see [LICENSE](LICENSE) file
35 |
--------------------------------------------------------------------------------
/mruby/mrbgems/stdlib-ext.gembox:
--------------------------------------------------------------------------------
1 | # It also works with MRB_NO_STDIO and MRB_NO_FLOAT.
2 |
3 | MRuby::GemBox.new do |conf|
4 | # Use standard Array#pack, String#unpack methods
5 | conf.gem :core => "mruby-pack"
6 |
7 | # Use standard Kernel#sprintf method
8 | conf.gem :core => "mruby-sprintf"
9 |
10 | # Use standard Time class
11 | conf.gem :core => "mruby-time"
12 |
13 | # Use standard Struct class
14 | conf.gem :core => "mruby-struct"
15 |
16 | # Use standard Data class
17 | conf.gem :core => "mruby-data"
18 |
19 | # Use Random class
20 | conf.gem :core => "mruby-random"
21 | end
22 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/patches/auto_config:
--------------------------------------------------------------------------------
1 | diff -pNr a/src/core/ngx_config.h b/src/core/ngx_config.h
2 | *** a/src/core/ngx_config.h 2008-09-19 13:47:13.000000000 +0100
3 | --- b/src/core/ngx_config.h 2010-10-09 17:14:13.000000000 +0100
4 | *************** typedef intptr_t ngx_flag_t;
5 | *** 127,131 ****
6 | #define NGX_MAX_UINT32_VALUE (uint32_t) 0xffffffff
7 | #endif
8 |
9 | !
10 | #endif /* _NGX_CONFIG_H_INCLUDED_ */
11 | --- 127,131 ----
12 | #define NGX_MAX_UINT32_VALUE (uint32_t) 0xffffffff
13 | #endif
14 |
15 | ! #include
16 | #endif /* _NGX_CONFIG_H_INCLUDED_ */
17 |
--------------------------------------------------------------------------------
/mruby/build_config.rb:
--------------------------------------------------------------------------------
1 | # The default build configuration file was moved to `build_config/default.rb`.
2 | #
3 | # Recommended way to customize the build configuration is:
4 | # * copy `default.rb` (or any config file) to a new file (e.g. `myconfig.rb`)
5 | # * edit `myconfig.rb`.
6 | # * `rake MRUBY_CONFIG=/path/to/myconfig.rb` to compile and test.
7 | # * or `rake MRUBY_CONFIG=myconfig` if your configuration file is in the `build_config` directory.
8 | # * (optional) submit your configuration as a pull-request if it's useful for others
9 | raise "The default configuration was moved to `build_config/default.rb`"
10 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # Toplevel Self(Ext) Test
3 |
4 | assert('Toplevel#include') do
5 | module ToplevelTestModule1
6 | def method_foo
7 | :foo
8 | end
9 |
10 | CONST_BAR = :bar
11 | end
12 |
13 | module ToplevelTestModule2
14 | CONST_BAR = :bar2
15 | end
16 |
17 | self.include ToplevelTestModule2, ToplevelTestModule1
18 |
19 | assert_true self.class.ancestors.include?( ToplevelTestModule1 )
20 | assert_true self.class.ancestors.include?( ToplevelTestModule2 )
21 | assert_equal :foo, method_foo
22 | assert_equal :bar2, CONST_BAR
23 | end
24 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_upstream_list.h:
--------------------------------------------------------------------------------
1 |
2 | #if (NDK_UPSTREAM_LIST_CMDS)
3 |
4 | /* TODO : use the generated commands */
5 |
6 | {
7 | ngx_string ("upstream_list"),
8 | NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_2MORE,
9 | ndk_upstream_list,
10 | 0,
11 | 0,
12 | NULL
13 | },
14 |
15 | #else
16 |
17 | typedef struct {
18 | ngx_str_t **elts;
19 | ngx_uint_t nelts;
20 | ngx_str_t name;
21 | } ndk_upstream_list_t;
22 |
23 |
24 | ndk_upstream_list_t *
25 | ndk_get_upstream_list (ndk_http_main_conf_t *mcf, u_char *data, size_t len);
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/mruby-YOUR-bigint/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-bigint') do |spec|
2 | spec.author = 'YOUR-NAME-HERE'
3 | spec.license = 'YOUR-LICENSE-HERE'
4 | spec.summary = 'Yet another multi-precision Integer extension'
5 | spec.homepage = 'https://gem.example/for/mruby-YOUR-bigint'
6 | spec.build.defines << 'MRB_USE_BIGINT'
7 | #spec.build.linker.libraries << 'gmp' # when uses libgmp
8 |
9 | spec.build.libmruby_core_objs << Dir.glob(File.join(__dir__, 'core/**/*.c')).map { |fn|
10 | objfile(fn.relative_path_from(__dir__).pathmap("#{spec.build_dir}/%X"))
11 | }
12 | end
13 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-time/include/mruby/time.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** mruby/time.h - Time class
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #ifndef MRUBY_TIME_H
8 | #define MRUBY_TIME_H
9 |
10 | #include "mruby/common.h"
11 | #include
12 |
13 | MRB_BEGIN_DECL
14 |
15 | typedef enum mrb_timezone {
16 | MRB_TIMEZONE_NONE = 0,
17 | MRB_TIMEZONE_UTC = 1,
18 | MRB_TIMEZONE_LOCAL = 2,
19 | MRB_TIMEZONE_LAST = 3
20 | } mrb_timezone;
21 |
22 | MRB_API mrb_value mrb_time_at(mrb_state *mrb, time_t sec, time_t usec, mrb_timezone timezone);
23 |
24 | MRB_END_DECL
25 |
26 | #endif /* MRUBY_TIME_H */
27 |
--------------------------------------------------------------------------------
/src/stream/ngx_stream_mruby_async.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_stream_mruby_async.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_stream_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_STREAM_MRUBY_ASYNC_H
8 | #define NGX_STREAM_MRUBY_ASYNC_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | mrb_value ngx_stream_mrb_start_fiber(ngx_stream_session_t *s, mrb_state *mrb, struct RProc *proc, mrb_value *result);
17 | void ngx_stream_mrb_async_class_init(mrb_state *mrb, struct RClass *class);
18 |
19 | #endif // NGX_STREAM_MRUBY_ASYNC_H
20 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-mrbc/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new 'mruby-bin-mrbc' do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'mruby compiler executable'
5 | spec.add_dependency 'mruby-compiler', :core => 'mruby-compiler'
6 |
7 | exec = exefile("#{build.build_dir}/bin/mrbc")
8 | mrbc_objs = Dir.glob("#{spec.dir}/tools/mrbc/*.c").map { |f| objfile(f.pathmap("#{spec.build_dir}/tools/mrbc/%n")) }
9 |
10 | file exec => mrbc_objs << build.libmruby_core_static do |t|
11 | build.linker.run t.name, t.prerequisites
12 | end
13 |
14 | build.bins << 'mrbc'
15 | end
16 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('mruby-socket') do |spec|
2 | spec.license = 'MIT'
3 | spec.authors = ['Internet Initiative Japan Inc.', 'mruby developers']
4 | spec.summary = 'standard socket class'
5 |
6 | #spec.cc.defines << "HAVE_SA_LEN=0"
7 |
8 | # If Windows, use winsock
9 | if spec.for_windows?
10 | spec.linker.libraries << "wsock32"
11 | spec.linker.libraries << "ws2_32"
12 | end
13 |
14 | spec.add_dependency('mruby-io', :core => 'mruby-io')
15 | spec.add_dependency('mruby-error', :core => 'mruby-error')
16 | # spec.add_dependency('mruby-mtest')
17 | end
18 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** mrdbconf.h - mruby debugger configuration
3 | **
4 | */
5 |
6 | #ifndef MRDBCONF_H
7 | #define MRDBCONF_H
8 |
9 | #ifndef MRB_USE_DEBUG_HOOK
10 | # error mruby-bin-debugger need 'MRB_USE_DEBUG_HOOK' in your build configuration
11 | #endif
12 |
13 | #ifdef MRB_NO_STDIO
14 | # error mruby-bin-debugger conflicts 'MRB_NO_STDIO' in your build configuration
15 | #endif
16 |
17 | /* configuration options: */
18 | /* maximum size for command buffer */
19 | #define MAX_COMMAND_LINE 1024
20 |
21 | /* maximum number of setable breakpoint */
22 | #define MAX_BREAKPOINT 5
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/mruby/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting a Vulnerability
4 |
5 | If you have any security concern, contact .
6 |
7 | ## Scope
8 |
9 | We consider the following issues as vulnerabilities:
10 |
11 | - Remote code execution
12 | - Crash caused by a valid Ruby script
13 |
14 | We _don't_ consider the following issues as vulnerabilities:
15 |
16 | - Runtime C undefined behavior (including integer overflow)
17 | - Crash caused by misused API
18 | - Crash caused by modified compiled binary
19 | - ASAN/Valgrind warning for too big memory allocation
20 | mruby assumes `malloc(3)` returns `NULL` for too big allocations
21 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-io/mrblib/kernel.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 | def `(cmd)
3 | IO.popen(cmd) { |io| io.read }
4 | end
5 |
6 | def open(file, *rest, &block)
7 | raise ArgumentError unless file.is_a?(String)
8 |
9 | if file[0] == "|"
10 | IO.popen(file[1..-1], *rest, &block)
11 | else
12 | File.open(file, *rest, &block)
13 | end
14 | end
15 |
16 | def print(*args)
17 | $stdout.print(*args)
18 | end
19 |
20 | def puts(*args)
21 | $stdout.puts(*args)
22 | end
23 |
24 | def printf(*args)
25 | $stdout.printf(*args)
26 | end
27 |
28 | def gets(*args)
29 | $stdin.gets(*args)
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_request.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_request.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_REQUEST_H
8 | #define NGX_HTTP_MRUBY_REQUEST_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | ngx_int_t ngx_mrb_push_request(ngx_http_request_t *r);
17 | ngx_http_request_t *ngx_mrb_get_request(void);
18 | mrb_value ngx_mrb_get_request_var(mrb_state *mrb, mrb_value self);
19 |
20 | void ngx_mrb_request_class_init(mrb_state *mrb, struct RClass *class);
21 |
22 | #endif // NGX_HTTP_MRUBY_REQUEST_H
23 |
--------------------------------------------------------------------------------
/mruby/build_config/ci/msvc.rb:
--------------------------------------------------------------------------------
1 | STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
2 |
3 | def setup_option(conf)
4 | conf.cc.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS']
5 | conf.cxx.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
6 | conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS']
7 | end
8 |
9 | MRuby::Build.new do |conf|
10 | conf.toolchain :visualcpp
11 |
12 | # include all core GEMs
13 | conf.gembox 'full-core'
14 | conf.compilers.each do |c|
15 | c.defines += %w(MRB_GC_FIXED_ARENA)
16 | end
17 | setup_option(conf)
18 | conf.enable_bintest
19 | conf.enable_test
20 | end
21 |
--------------------------------------------------------------------------------
/src/http/ngx_http_mruby_async.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_http_mruby_async.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_HTTP_MRUBY_ASYNC_H
8 | #define NGX_HTTP_MRUBY_ASYNC_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | mrb_value ngx_mrb_start_fiber(ngx_http_request_t *r, mrb_state *mrb, struct RProc *proc, mrb_value *result);
17 | mrb_value ngx_mrb_run_fiber(mrb_state *mrb, mrb_value *fiber, mrb_value *result);
18 |
19 | void ngx_mrb_async_class_init(mrb_state *mrb, struct RClass *class);
20 |
21 | #endif // NGX_HTTP_MRUBY_ASYNC_H
22 |
--------------------------------------------------------------------------------
/mruby/mruby-source.gemspec:
--------------------------------------------------------------------------------
1 | lib = File.expand_path('../lib', __FILE__)
2 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3 | require 'mruby/source'
4 |
5 | Gem::Specification.new do |spec|
6 | spec.name = "mruby-source"
7 | spec.version = MRuby::Source::MRUBY_VERSION
8 | spec.authors = [ MRuby::Source::MRUBY_AUTHOR ]
9 |
10 | spec.summary = %q{mruby source code wrapper.}
11 | spec.description = %q{mruby source code wrapper for use with Ruby libs.}
12 | spec.homepage = "https://mruby.org"
13 | spec.license = "MIT"
14 |
15 | spec.files = `git ls-files -z`.split("\x0")
16 | spec.require_paths = ["lib"]
17 | end
18 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_string_util.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #define ndk_str_init(ns,s) {(ns).data = (u_char*) s; (ns).len = sizeof (s) - 1;}
4 | #define ndk_strp_init(ns,s) {(ns)->data = (u_char*) s; (ns)->len = sizeof (s) - 1;}
5 |
6 | #define ndk_zero(p,sz) memset (p,'\0',sz)
7 | #define ndk_zerop(p) ndk_zero (p,sizeof(*p))
8 | #define ndk_zeropn(p,n) ndk_zero (p,sizeof(*p)*(n))
9 | #define ndk_zerov(v) ndk_zero (&v,sizeof(v))
10 |
11 | #define ngx_null_enum { ngx_null_string, 0 }
12 |
13 | #define ndk_memcpyp(d,s) ngx_memcpy(d,s,sizeof(s))
14 |
15 |
--------------------------------------------------------------------------------
/mruby/mrbgems/default.gembox:
--------------------------------------------------------------------------------
1 | MRuby::GemBox.new do |conf|
2 | conf.gembox "stdlib"
3 | conf.gembox "stdlib-ext"
4 | conf.gembox "stdlib-io"
5 | conf.gembox "math"
6 | conf.gembox "metaprog"
7 |
8 | # Generate mrbc command
9 | conf.gem :core => "mruby-bin-mrbc"
10 |
11 | # Generate mrdb command
12 | conf.gem :core => "mruby-bin-debugger"
13 |
14 | # Generate mirb command
15 | conf.gem :core => "mruby-bin-mirb"
16 |
17 | # Generate mruby command
18 | conf.gem :core => "mruby-bin-mruby"
19 |
20 | # Generate mruby-strip command
21 | conf.gem :core => "mruby-bin-strip"
22 |
23 | # Generate mruby-config command
24 | conf.gem :core => "mruby-bin-config"
25 | end
26 |
--------------------------------------------------------------------------------
/mruby/Makefile:
--------------------------------------------------------------------------------
1 | # mruby is using Rake (https://ruby.github.io/rake/) as a build tool.
2 |
3 | RAKE = rake
4 |
5 | all :
6 | $(RAKE)
7 | .PHONY : all
8 |
9 | test : all
10 | $(RAKE) test
11 | .PHONY : test
12 |
13 | clean :
14 | $(RAKE) clean
15 | .PHONY : clean
16 |
17 | check :
18 | pre-commit run --all-files
19 | .PHONY : check
20 |
21 | checkinstall :
22 | pre-commit install
23 | .PHONY : checkinstall
24 |
25 | checkupdate :
26 | pre-commit autoupdate
27 | .PHONY : checkupdate
28 |
29 | composecheck :
30 | docker-compose -p mruby run test pre-commit run --all-files
31 | .PHONY : composecheck
32 |
33 | composetest :
34 | docker-compose -p mruby run test
35 | .PHONY : composetest
36 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_extension_example/src/example.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | static mrb_value
6 | mrb_c_method(mrb_state *mrb, mrb_value self)
7 | {
8 | mrb_ensure_string_type(mrb, self);
9 | printf("%s: A C Extension\n", mrb_str_to_cstr(mrb, self));
10 |
11 | return self;
12 | }
13 |
14 | void
15 | mrb_c_extension_example_gem_init(mrb_state* mrb) {
16 | struct RClass *class_cextension = mrb_define_module(mrb, "CExtension");
17 | mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE());
18 | }
19 |
20 | void
21 | mrb_c_extension_example_gem_final(mrb_state* mrb) {
22 | /* finalizer */
23 | }
24 |
--------------------------------------------------------------------------------
/mruby/test/t/symbol.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # Symbol ISO Test
3 |
4 | assert('Symbol') do
5 | assert_equal :"a", :a
6 | assert_equal :"a#{1}", :a1
7 | assert_equal :'a', :a
8 | assert_equal :'a#{1}', :"a\#{1}"
9 | end
10 |
11 | assert('Symbol', '15.2.11') do
12 | assert_equal Class, Symbol.class
13 | end
14 |
15 | assert('Symbol#===', '15.2.11.3.1') do
16 | assert_true :abc === :abc
17 | assert_false :abc === :cba
18 | end
19 |
20 | assert('Symbol#to_s', '15.2.11.3.3') do
21 | assert_equal 'abc', :abc.to_s
22 | end
23 |
24 | assert('Symbol#to_sym', '15.2.11.3.4') do
25 | assert_equal :abc, :abc.to_sym
26 | end
27 |
28 | assert('Symbol#to_proc') do
29 | assert_equal 5, :abs.to_proc[-5]
30 | end
31 |
--------------------------------------------------------------------------------
/docker/hook/proxy.rb:
--------------------------------------------------------------------------------
1 | # location /proxy {
2 | # mruby_set $backend "/path/to/proxy.rb";
3 | # proxy_pass http://$backend;
4 | # }
5 |
6 | backends = [
7 | "127.0.0.1:80",
8 | ]
9 |
10 | unless ENV["PROXY1_PORT_80_TCP_ADDR"].nil?
11 | backends << ENV["PROXY1_PORT_80_TCP_ADDR"] + ":" + ENV["PROXY1_PORT_80_TCP_PORT"]
12 | end
13 |
14 | unless ENV["PROXY2_PORT_80_TCP_ADDR"].nil?
15 | backends << ENV["PROXY2_PORT_80_TCP_ADDR"] + ":" + ENV["PROXY2_PORT_80_TCP_PORT"]
16 | end
17 |
18 | unless ENV["PROXY3_PORT_80_TCP_ADDR"].nil?
19 | backends << ENV["PROXY3_PORT_80_TCP_ADDR"] + ":" + ENV["PROXY3_PORT_80_TCP_PORT"]
20 | end
21 |
22 | uri = '/mruby-hello'
23 |
24 | backends[rand(backends.length)] + uri
25 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | static mrb_value
6 | mrb_c_method(mrb_state *mrb, mrb_value self)
7 | {
8 | mrb_ensure_string_type(mrb, self);
9 | printf("%s: A C Extension\n", mrb_str_to_cstr(mrb, self));
10 |
11 | return self;
12 | }
13 |
14 | void
15 | mrb_c_and_ruby_extension_example_gem_init(mrb_state* mrb) {
16 | struct RClass *class_cextension = mrb_define_module(mrb, "CRubyExtension");
17 | mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE());
18 | }
19 |
20 | void
21 | mrb_c_and_ruby_extension_example_gem_final(mrb_state* mrb) {
22 | /* finalizer */
23 | }
24 |
--------------------------------------------------------------------------------
/example/unified_hello.rb:
--------------------------------------------------------------------------------
1 | # Unified Ruby Code between Apache(mod_mruby) and nginx(ngx_mruby)
2 | # for Web server extensions.
3 | #
4 | # Apache httpd.conf by mod_mruby
5 | #
6 | #
7 | # mrubyHandlerMiddle "/path/to/unified_hello.rb"
8 | #
9 | #
10 | # nginx nginx.conf by ngx_mruby
11 | #
12 | # location /mruby {
13 | # mruby_content_handler "/path/to/unified_hello.rb";
14 | # }
15 | #
16 |
17 | if server_name == "NGINX"
18 | Server = Nginx
19 | elsif server_name == "Apache"
20 | Server = Apache
21 | end
22 |
23 | Server::rputs "Hello #{Server::module_name}/#{Server::module_version} world!"
24 | # mod_mruby => "Hello mod_mruby/0.9.3 world!"
25 | # ngx_mruby => "Hello ngx_mruby/0.0.1 world!"
26 |
--------------------------------------------------------------------------------
/mruby/test/t/nameerror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # NameError ISO Test
3 |
4 | assert('NameError', '15.2.31') do
5 | assert_equal Class, NameError.class
6 | end
7 |
8 | assert('NameError#name', '15.2.31.2.1') do
9 |
10 | # This check is not duplicate with 15.2.31.2.2 check.
11 | # Because the NameError in this test is generated in
12 | # C API.
13 | class TestDummy
14 | alias foo bar
15 | rescue NameError => e
16 | $test_dummy_result = e.name
17 | end
18 |
19 | assert_equal :bar, $test_dummy_result
20 | end
21 |
22 | assert('NameError#initialize', '15.2.31.2.2') do
23 | e = NameError.new('a', :foo)
24 |
25 | assert_equal NameError, e.class
26 | assert_equal 'a', e.message
27 | assert_equal :foo, e.name
28 | end
29 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/patches/rewrite_phase_handler:
--------------------------------------------------------------------------------
1 | diff -p -r a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
2 | *** a/src/http/ngx_http_core_module.c 2010-09-27 12:48:12.000000000 +0100
3 | --- b/src/http/ngx_http_core_module.c 2010-10-09 13:44:09.000000000 +0100
4 | *************** ngx_http_core_rewrite_phase(ngx_http_req
5 | *** 910,915 ****
6 | --- 910,922 ----
7 | return NGX_AGAIN;
8 | }
9 |
10 | + #if defined(nginx_version) && nginx_version >= 8042 && (NDK_REWRITE_PHASE)
11 | +
12 | + if (rc == NGX_AGAIN || rc == NGX_DONE) {
13 | + return NGX_OK;
14 | + }
15 | +
16 | + #endif
17 | /* rc == NGX_OK || rc == NGX_ERROR || rc == NGX_HTTP_... */
18 |
19 | ngx_http_finalize_request(r, rc);
20 |
--------------------------------------------------------------------------------
/mruby/test/t/true.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # TrueClass ISO Test
3 |
4 | assert('TrueClass', '15.2.5') do
5 | assert_equal Class, TrueClass.class
6 | end
7 |
8 | assert('TrueClass true', '15.2.5.1') do
9 | assert_true true
10 | assert_equal TrueClass, true.class
11 | assert_false TrueClass.method_defined? :new
12 | end
13 |
14 | assert('TrueClass#&', '15.2.5.3.1') do
15 | assert_true true.&(true)
16 | assert_false true.&(false)
17 | end
18 |
19 | assert('TrueClass#^', '15.2.5.3.2') do
20 | assert_false true.^(true)
21 | assert_true true.^(false)
22 | end
23 |
24 | assert('TrueClass#to_s', '15.2.5.3.3') do
25 | assert_equal 'true', true.to_s
26 | end
27 |
28 | assert('TrueClass#|', '15.2.5.3.4') do
29 | assert_true true.|(true)
30 | assert_true true.|(false)
31 | end
32 |
--------------------------------------------------------------------------------
/mruby/test/t/bs_literal.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # Bootstrap test for literals
3 |
4 | assert('BS Literal 1') do
5 | assert_true true
6 | end
7 |
8 | assert('BS Literal 2') do
9 | assert_equal TrueClass, true.class
10 | end
11 |
12 | assert('BS Literal 3') do
13 | assert_false false
14 | end
15 |
16 | assert('BS Literal 4') do
17 | assert_equal FalseClass, false.class
18 | end
19 |
20 | assert('BS Literal 5') do
21 | assert_equal 'nil', nil.inspect
22 | end
23 |
24 | assert('BS Literal 6') do
25 | assert_equal NilClass, nil.class
26 | end
27 |
28 | assert('BS Literal 7') do
29 | assert_equal Symbol, :sym.class
30 | end
31 |
32 | assert('BS Literal 8') do
33 | assert_equal 1234, 1234
34 | end
35 |
36 | assert('BS Literal 9') do
37 | assert_equal Integer, 1234.class
38 | end
39 |
--------------------------------------------------------------------------------
/test/html/unified_hello.rb:
--------------------------------------------------------------------------------
1 | # Unified Ruby Code between Apache(mod_mruby) and nginx(ngx_mruby)
2 | # for Web server extensions.
3 | #
4 | # Apache httpd.conf by mod_mruby
5 | #
6 | #
7 | # mrubyHandlerMiddle "/path/to/unified_hello.rb"
8 | #
9 | #
10 | # nginx nginx.conf by ngx_mruby
11 | #
12 | # location /mruby {
13 | # mruby_content_handler "/path/to/unified_hello.rb";
14 | # }
15 | #
16 |
17 | if server_name == "NGINX"
18 | Server = Nginx
19 | elsif server_name == "Apache"
20 | Server = Apache
21 | end
22 |
23 | Server::rputs "Hello #{Server::module_name} world!"
24 | #Server::rputs "Hello #{Server::module_name}/#{Server::module_version} world!"
25 | # mod_mruby => "Hello mod_mruby/0.9.3 world!"
26 | # ngx_mruby => "Hello ngx_mruby/0.0.1 world!"
27 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-proc-binding/test/proc-binding.rb:
--------------------------------------------------------------------------------
1 | assert "Proc#binding" do
2 | block = ->(i) {}
3 | a, b, c = 1, 2, 3
4 | bind = block.binding
5 | assert_equal([:a, :b, :bind, :block, :c], bind.local_variables.sort)
6 | assert_equal(1, bind.local_variable_get(:a))
7 | assert_equal(5, bind.eval("b + c"))
8 | bind.local_variable_set(:x, 9)
9 | assert_equal(9, bind.local_variable_get(:x))
10 | end
11 |
12 | assert("Binding#source_location after Proc#binding") do
13 | skip unless -> {}.source_location
14 |
15 | block, source_location = -> {}, [__FILE__, __LINE__]
16 | assert_equal source_location, block.binding.source_location
17 | end
18 |
19 | assert "Proc#binding and .eval from C" do
20 | bind = proc_in_c.binding
21 | assert_nothing_raised { bind.eval("self") }
22 | end
23 |
--------------------------------------------------------------------------------
/mruby/test/t/false.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # FalseClass ISO Test
3 |
4 | assert('FalseClass', '15.2.6') do
5 | assert_equal Class, FalseClass.class
6 | end
7 |
8 | assert('FalseClass false', '15.2.6.1') do
9 | assert_false false
10 | assert_equal FalseClass, false.class
11 | assert_false FalseClass.method_defined? :new
12 | end
13 |
14 | assert('FalseClass#&', '15.2.6.3.1') do
15 | assert_false false.&(true)
16 | assert_false false.&(false)
17 | end
18 |
19 | assert('FalseClass#^', '15.2.6.3.2') do
20 | assert_true false.^(true)
21 | assert_false false.^(false)
22 | end
23 |
24 | assert('FalseClass#to_s', '15.2.6.3.3') do
25 | assert_equal 'false', false.to_s
26 | end
27 |
28 | assert('FalseClass#|', '15.2.6.3.4') do
29 | assert_true false.|(true)
30 | assert_false false.|(false)
31 | end
32 |
--------------------------------------------------------------------------------
/mruby/mrblib/00class.rb:
--------------------------------------------------------------------------------
1 | class BasicObject
2 | def !=(other)
3 | if self == other
4 | false
5 | else
6 | true
7 | end
8 | end
9 | end
10 |
11 | class Module
12 | # 15.2.2.4.12
13 | def attr_accessor(*names)
14 | attr_reader(*names)
15 | attr_writer(*names)
16 | end
17 | # 15.2.2.4.11
18 | alias attr attr_reader
19 | #def attr(name)
20 | # attr_reader(name)
21 | #end
22 |
23 | # 15.2.2.4.27
24 | def include(*args)
25 | args.reverse!
26 | args.each do |m|
27 | m.append_features(self)
28 | m.included(self)
29 | end
30 | self
31 | end
32 |
33 | def prepend(*args)
34 | args.reverse!
35 | args.each do |m|
36 | m.prepend_features(self)
37 | m.prepended(self)
38 | end
39 | self
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/mruby/test/t/ensure.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # ensure Test
3 |
4 | class EnsureYieldBreak
5 | attr_reader :ensure_context
6 | def try
7 | yield
8 | ensure
9 | @ensure_context = self
10 | end
11 | end
12 |
13 | assert('ensure - context - yield') do
14 | yielder = EnsureYieldBreak.new
15 | yielder.try do
16 | end
17 | assert_equal yielder, yielder.ensure_context
18 | end
19 |
20 | assert('ensure - context - yield and break') do
21 | yielder = EnsureYieldBreak.new
22 | yielder.try do
23 | break
24 | end
25 | assert_equal yielder, yielder.ensure_context
26 | end
27 |
28 | assert('ensure - context - yield and return') do
29 | yielder = EnsureYieldBreak.new
30 | lambda do
31 | yielder.try do
32 | return
33 | end
34 | end.call
35 | assert_equal yielder, yielder.ensure_context
36 | end
37 |
--------------------------------------------------------------------------------
/mruby/.github/workflows/oss-fuzz.yml:
--------------------------------------------------------------------------------
1 | # https://github.com/google/oss-fuzz
2 | name: CIFuzz
3 | on: [pull_request]
4 | permissions:
5 | contents: read
6 |
7 | jobs:
8 | Fuzzing:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: Build Fuzzers
12 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
13 | with:
14 | oss-fuzz-project-name: "mruby"
15 | dry-run: false
16 | - name: Run Fuzzers
17 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
18 | with:
19 | oss-fuzz-project-name: "mruby"
20 | fuzz-seconds: 600
21 | dry-run: false
22 | - name: Upload Crash
23 | uses: actions/upload-artifact@v4
24 | if: failure()
25 | with:
26 | name: artifacts
27 | path: ./out/artifacts
28 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apistring.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** apistring.c
3 | **
4 | */
5 |
6 | #include
7 | #include "apistring.h"
8 |
9 | static size_t
10 | mrb_debug_strnlen(const char *s, size_t maxlen)
11 | {
12 | const char *p = (const char*)memchr(s, '\0', maxlen);
13 | return p != NULL ? (size_t)(p - s) : maxlen;
14 | }
15 |
16 | char*
17 | mrdb_strndup(mrb_state *mrb, const char *s, size_t size)
18 | {
19 | size_t l = mrb_debug_strnlen(s, size);
20 | char *d = (char*)mrb_malloc_simple(mrb, l + 1);
21 | if (d != NULL) {
22 | memcpy(d, s, l);
23 | d[l] = '\0';
24 | }
25 | return d;
26 | }
27 |
28 | char*
29 | mrdb_strdup(mrb_state *mrb, const char *s)
30 | {
31 | size_t z = strlen(s) + 1;
32 | char *d = (char*)mrb_malloc_simple(mrb, z);
33 | return d != NULL ? (char*)memcpy(d, s, z) : NULL;
34 | }
35 |
--------------------------------------------------------------------------------
/mruby/.editorconfig:
--------------------------------------------------------------------------------
1 | # About this file, see:
2 | # Website: https://editorconfig.org/
3 | # For Emacs users: https://github.com/editorconfig/editorconfig-emacs
4 | # For Vim users: https://github.com/editorconfig/editorconfig-vim
5 |
6 | root = true
7 |
8 | [*]
9 | charset = utf-8
10 | end_of_line = lf
11 | indent_size = 2
12 | indent_style = space
13 | insert_final_newline = true
14 | tab_width = 8
15 | trim_trailing_whitespace = true
16 |
17 | [{Makefile,Makefile.*,makefile,*.mk}]
18 | indent_style = tab
19 | #max_line_length = 80
20 |
21 | #[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
22 | #max_line_length = 120
23 |
24 | #[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
25 | #max_line_length = 120
26 |
27 | # limitation to US-ASCII
28 | [*.bat]
29 | end_of_line = crlf
30 | #max_line_length = 80
31 |
32 | #[*.{yaml,yml}]
33 |
34 | #[*.md]
35 |
--------------------------------------------------------------------------------
/mruby/mrblib/00kernel.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 | ##
3 | # call-seq:
4 | # obj.extend(module, ...) -> obj
5 | #
6 | # Adds to _obj_ the instance methods from each module given as a
7 | # parameter.
8 | #
9 | # module Mod
10 | # def hello
11 | # "Hello from Mod.\n"
12 | # end
13 | # end
14 | #
15 | # class Klass
16 | # def hello
17 | # "Hello from Klass.\n"
18 | # end
19 | # end
20 | #
21 | # k = Klass.new
22 | # k.hello #=> "Hello from Klass.\n"
23 | # k.extend(Mod) #=> #
24 | # k.hello #=> "Hello from Mod.\n"
25 | #
26 | # ISO 15.3.1.3.13
27 | def extend(*args)
28 | args.reverse!
29 | args.each do |m|
30 | m.extend_object(self)
31 | m.extended(self)
32 | end
33 | self
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/mruby/src/enum.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** enum.c - Enumerable module
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | /* internal method `__update_hash(oldhash, index, itemhash)` */
12 | static mrb_value
13 | enum_update_hash(mrb_state *mrb, mrb_value self)
14 | {
15 | mrb_int hash;
16 | mrb_int index;
17 | mrb_int hv;
18 |
19 | mrb_get_args(mrb, "iii", &hash, &index, &hv);
20 | hash ^= ((uint32_t)hv << (index % 16));
21 |
22 | return mrb_int_value(mrb, hash);
23 | }
24 |
25 | void
26 | mrb_init_enumerable(mrb_state *mrb)
27 | {
28 | struct RClass *enumerable;
29 | enumerable = mrb_define_module_id(mrb, MRB_SYM(Enumerable)); /* 15.3.2 */
30 | mrb_define_module_function_id(mrb, enumerable, MRB_SYM(__update_hash), enum_update_hash, MRB_ARGS_REQ(3));
31 | }
32 |
--------------------------------------------------------------------------------
/mruby/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | # https://pre-commit.com/
2 | name: Lint
3 |
4 | on: [pull_request]
5 |
6 | permissions:
7 | contents: read
8 |
9 | jobs:
10 | pre-commit:
11 | name: Run pre-commit
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
15 | uses: actions/checkout@v4
16 | - name: Install
17 | run: |
18 | python -m pip install --upgrade pip
19 | pip install pre-commit
20 | - name: Set PY
21 | run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
22 | - uses: actions/cache@v4
23 | with:
24 | path: ~/.cache/pre-commit
25 | key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
26 | - name: Run pre-commit
27 | run: pre-commit run --all-files
28 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-class-ext/test/class.rb:
--------------------------------------------------------------------------------
1 | assert 'Class#subclasses' do
2 | a = Class.new
3 | b = Class.new(a)
4 | c = Class.new(b)
5 | d = Class.new(a)
6 |
7 | a_sub = a.subclasses
8 | assert_equal(2, a_sub.size)
9 | assert_true(a_sub.include?(b))
10 | assert_true(a_sub.include?(d))
11 | assert_equal([c], b.subclasses)
12 | assert_equal([], c.subclasses)
13 | end
14 |
15 | assert 'Class#attached_object' do
16 | foo = Class.new
17 | foo_s = class <
2 | #include
3 |
4 | void
5 | mrb_init_version(mrb_state* mrb)
6 | {
7 | mrb_value mruby_version = mrb_str_new_lit(mrb, MRUBY_VERSION);
8 |
9 | mrb_define_global_const(mrb, "RUBY_VERSION", mrb_str_new_lit(mrb, MRUBY_RUBY_VERSION));
10 | mrb_define_global_const(mrb, "RUBY_ENGINE", mrb_str_new_lit(mrb, MRUBY_RUBY_ENGINE));
11 | mrb_define_global_const(mrb, "RUBY_ENGINE_VERSION", mruby_version);
12 | mrb_define_global_const(mrb, "MRUBY_VERSION", mruby_version);
13 | mrb_define_global_const(mrb, "MRUBY_RELEASE_NO", mrb_fixnum_value(MRUBY_RELEASE_NO));
14 | mrb_define_global_const(mrb, "MRUBY_RELEASE_DATE", mrb_str_new_lit(mrb, MRUBY_RELEASE_DATE));
15 | mrb_define_global_const(mrb, "MRUBY_DESCRIPTION", mrb_str_new_lit(mrb, MRUBY_DESCRIPTION));
16 | mrb_define_global_const(mrb, "MRUBY_COPYRIGHT", mrb_str_new_lit(mrb, MRUBY_COPYRIGHT));
17 | }
18 |
--------------------------------------------------------------------------------
/mruby/test/t/nil.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # NilClass ISO Test
3 |
4 | assert('NilClass', '15.2.4') do
5 | assert_equal Class, NilClass.class
6 | end
7 |
8 | assert('NilClass', '15.2.4.1') do
9 | assert_equal NilClass, nil.class
10 | assert_false NilClass.method_defined? :new
11 | end
12 |
13 | assert('NilClass#&', '15.2.4.3.1') do
14 | assert_false nil.&(true)
15 | assert_false nil.&(nil)
16 | end
17 |
18 | assert('NilClass#^', '15.2.4.3.2') do
19 | assert_true nil.^(true)
20 | assert_false nil.^(false)
21 | end
22 |
23 | assert('NilClass#|', '15.2.4.3.3') do
24 | assert_true nil.|(true)
25 | assert_false nil.|(false)
26 | end
27 |
28 | assert('NilClass#nil?', '15.2.4.3.4') do
29 | assert_true nil.nil?
30 | end
31 |
32 | assert('NilClass#to_s', '15.2.4.3.5') do
33 | assert_equal '', nil.to_s
34 | end
35 |
36 | assert('safe navigation') do
37 | assert_nil nil&.size
38 | assert_equal 0, []&.size
39 | end
40 |
--------------------------------------------------------------------------------
/src/stream/ngx_stream_mruby_core.h:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_stream_mruby_core.h - ngx_mruby mruby module header
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #ifndef NGX_STREAM_MRUBY_CORE_H
8 | #define NGX_STREAM_MRUBY_CORE_H
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | void ngx_stream_mrb_core_class_init(mrb_state *mrb, struct RClass *class);
17 | typedef void (*ngx_stream_mrb_cleanup_pt)(void *data);
18 | typedef struct ngx_stream_mruby_ctx_t {
19 | mrb_value *fiber_proc;
20 | mrb_value *async_handler_result;
21 | ngx_stream_mrb_cleanup_pt cleanup;
22 | ngx_event_t sleep;
23 | } ngx_stream_mruby_ctx_t;
24 |
25 | ngx_stream_mruby_ctx_t *ngx_stream_mrb_get_module_ctx(mrb_state *mrb, ngx_stream_session_t *s);
26 |
27 | extern ngx_module_t ngx_stream_mruby_module;
28 |
29 | #endif // NGX_STREAM_MRUBY_CORE_H
30 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-print/mrblib/print.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # Kernel
3 | #
4 | # ISO 15.3.1
5 | module Kernel
6 | ##
7 | # Print human readable object description
8 | #
9 | # ISO 15.3.1.2.9 Kernel.p
10 | # ISO 15.3.1.3.34 Kernel#p
11 | def p(*args)
12 | i = 0
13 | len = args.size
14 | while i < len
15 | print args[i].inspect, "\n"
16 | i += 1
17 | end
18 | args.__svalue
19 | end
20 |
21 | # ISO 15.3.1.2.11 Kernel.puts
22 | # ISO 15.3.1.3.39 Kernel#puts
23 | def puts(*args)
24 | i = 0
25 | len = args.size
26 | while i < len
27 | s = args[i]
28 | if s.kind_of?(Array)
29 | puts(*s)
30 | else
31 | s = s.to_s
32 | print s
33 | print "\n" if (s[-1] != "\n")
34 | end
35 | i += 1
36 | end
37 | print "\n" if len == 0
38 | end
39 |
40 | def printf(*args)
41 | print(sprintf(*args))
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/mruby/tasks/bin.rake:
--------------------------------------------------------------------------------
1 | MRuby.each_target do |build|
2 | if build.host? && build.mrbc_build && !build.gems["mruby-bin-mrbc"]
3 | exe = build.exefile("#{build.mrbc_build.build_dir}/bin/mrbc")
4 | build.products << build.define_installer(exe)
5 | end
6 |
7 | build.bins.each{|bin| build.products << define_installer_if_needed(bin)}
8 |
9 | build.gems.each do |gem|
10 | linker_attrs = build.gems.linker_attrs(gem)
11 | gem.bins.each do |bin|
12 | exe = build.exefile("#{build.build_dir}/bin/#{bin}")
13 | objs = Dir["#{gem.dir}/tools/#{bin}/*.{c,cpp,cxx,cc}"].map do |f|
14 | build.objfile(f.pathmap("#{gem.build_dir}/tools/#{bin}/%n"))
15 | end
16 | file exe => objs.concat(build.libraries) do |t|
17 | build.linker.run t.name, t.prerequisites, *linker_attrs
18 | end
19 |
20 | build.products << define_installer_if_needed(bin)
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_complex_value.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | typedef struct {
4 | ngx_str_t key;
5 | ngx_http_complex_value_t value;
6 | } ndk_http_complex_keyval_t;
7 |
8 |
9 |
10 | /* create/compile functions */
11 |
12 | ngx_int_t ndk_http_complex_value_compile (ngx_conf_t *cf, ngx_http_complex_value_t *cv, ngx_str_t *value);
13 | ngx_array_t * ndk_http_complex_value_array_create (ngx_conf_t *cf, char **s, ngx_int_t n);
14 | ngx_int_t ndk_http_complex_value_array_compile (ngx_conf_t *cf, ngx_array_t *a);
15 |
16 |
17 | /* conf set slot functions */
18 |
19 | char * ndk_conf_set_http_complex_keyval_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
20 | char * ndk_conf_set_http_complex_value_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
21 | char * ndk_conf_set_http_complex_value_array_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
22 |
--------------------------------------------------------------------------------
/mruby/mrblib/kernel.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # Kernel
3 | #
4 | # ISO 15.3.1
5 | module Kernel
6 |
7 | # 15.3.1.2.1 Kernel.`
8 | # provided by Kernel#`
9 | # 15.3.1.3.3
10 | def `(s)
11 | raise NotImplementedError.new("backquotes not implemented")
12 | end
13 |
14 | ##
15 | # 15.3.1.2.3 Kernel.eval
16 | # 15.3.1.3.12 Kernel#eval
17 | # NotImplemented by mruby core; use mruby-eval gem
18 |
19 | ##
20 | # ISO 15.3.1.2.8 Kernel.loop
21 | # provided by Kernel#loop
22 |
23 | ##
24 | # Calls the given block repetitively.
25 | #
26 | # ISO 15.3.1.3.29
27 | def loop(&block)
28 | return to_enum :loop unless block
29 |
30 | while true
31 | yield
32 | end
33 | rescue StopIteration => e
34 | e.result
35 | end
36 |
37 | # 11.4.4 Step c)
38 | def !~(y)
39 | !(self =~ y)
40 | end
41 |
42 | def to_enum(*a)
43 | raise NotImplementedError.new("fiber required for enumerator")
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_rewrite.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* TODO : should remove this when not needed */
4 |
5 |
6 |
7 | /* used for plugging into the rewrite module (taken from the rewrite module) */
8 |
9 | typedef struct {
10 | ngx_array_t *codes; /* uintptr_t */
11 | ngx_uint_t stack_size;
12 | ngx_flag_t log;
13 | ngx_flag_t uninitialized_variable_warn;
14 | } ndk_http_rewrite_loc_conf_t;
15 |
16 |
17 | extern ngx_module_t ngx_http_rewrite_module;
18 | extern uintptr_t ndk_http_script_exit_code;
19 |
20 | char * ndk_http_rewrite_value (ngx_conf_t *cf, ndk_http_rewrite_loc_conf_t *lcf,
21 | ngx_str_t *value);
22 | ngx_int_t ndk_http_rewrite_var (ngx_http_request_t *r,
23 | ngx_http_variable_value_t *v, uintptr_t data);
24 |
25 | #define ndk_http_script_exit (u_char *) &ndk_http_script_exit_code
26 |
27 |
--------------------------------------------------------------------------------
/mruby/build_config/host-shared.rb:
--------------------------------------------------------------------------------
1 | # NOTE: Currently, this configuration file does not support VisualC++!
2 | # Your help is needed!
3 |
4 | MRuby::Build.new do |conf|
5 | # load specific toolchain settings
6 | conf.toolchain
7 |
8 | # include the GEM box
9 | conf.gembox 'default'
10 |
11 | # C compiler settings
12 | conf.compilers.each do |cc|
13 | cc.flags << '-fPIC'
14 | end
15 |
16 | conf.archiver do |archiver|
17 | archiver.command = cc.command
18 | archiver.archive_options = '-shared -o %{outfile} %{objs}'
19 | end
20 |
21 | # file extensions
22 | conf.exts do |exts|
23 | exts.library = '.so'
24 | end
25 |
26 | # file separator
27 | # conf.file_separator = '/'
28 |
29 | # enable this if better compatibility with C++ is desired
30 | #conf.enable_cxx_exception
31 |
32 | # Turn on `enable_debug` for better debugging
33 | conf.enable_debug
34 | conf.enable_bintest
35 | conf.enable_test
36 | end
37 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-sleep/test/sleep_test.rb:
--------------------------------------------------------------------------------
1 | assert("sleep works") do
2 | assert_nothing_raised { sleep(1) }
3 | assert_nothing_raised { sleep(0) }
4 | end
5 |
6 | assert("sleep would accept non-negative float value") do
7 | skip unless Object.const_defined?(:Float)
8 | assert_nothing_raised { sleep(0.01) }
9 | assert_nothing_raised { sleep(0.0) }
10 | assert_nothing_raised { sleep(-0.0) }
11 | end
12 |
13 | assert("sleep would not accept negative integer value") do
14 | assert_raise(ArgumentError) { sleep(-1) }
15 | end
16 |
17 | assert("sleep would not accept negative float value") do
18 | skip unless Object.const_defined?(:Float)
19 | assert_raise(ArgumentError) { sleep(-0.1) }
20 | end
21 |
22 | assert("usleep works") do
23 | assert_nothing_raised { usleep(100) }
24 | assert_nothing_raised { usleep(0) }
25 | end
26 |
27 | assert("usleep would not accept negative value") do
28 | assert_raise(ArgumentError) { usleep(-100) }
29 | end
30 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_extension_example/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('c_extension_example') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 |
5 | # Add compile flags
6 | # spec.cc.flags << '-g'
7 |
8 | # Add cflags to all
9 | # spec.mruby.cc.flags << '-g'
10 |
11 | # Add libraries
12 | # spec.linker.libraries << 'external_lib'
13 |
14 | # Default build files
15 | # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
16 | # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
17 | # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
18 | # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
19 | # spec.test_preload = 'test/assert.rb'
20 |
21 | # Values accessible as TEST_ARGS inside test scripts
22 | # spec.test_args = {'tmp_dir' => Dir::tmpdir}
23 | end
24 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-string-ext/test/range.rb:
--------------------------------------------------------------------------------
1 | assert('Range#max') do
2 | # returns the maximum value in the range when called with no arguments
3 | assert_equal 'l', ('f'..'l').max
4 | assert_equal 'e', ('a'...'f').max
5 |
6 | # returns nil when the endpoint is less than the start point
7 | assert_equal nil, ('z'..'l').max
8 | end
9 |
10 | assert('Range#max given a block') do
11 | # returns nil when the endpoint is less than the start point
12 | assert_equal nil, (('z'..'l').max { |x, y| x <=> y })
13 | end
14 |
15 | assert('Range#min') do
16 | # returns the minimum value in the range when called with no arguments
17 | assert_equal 'f', ('f'..'l').min
18 |
19 | # returns nil when the start point is greater than the endpoint
20 | assert_equal nil, ('z'..'l').min
21 | end
22 |
23 | assert('Range#min given a block') do
24 | # returns nil when the start point is greater than the endpoint
25 | assert_equal nil, (('z'..'l').min { |x, y| x <=> y })
26 | end
27 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/cdata_extension_example/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('cdata_extension_example') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 |
5 | # Add compile flags
6 | # spec.cc.flags << '-g'
7 |
8 | # Add cflags to all
9 | # spec.mruby.cc.flags << '-g'
10 |
11 | # Add libraries
12 | # spec.linker.libraries << 'external_lib'
13 |
14 | # Default build files
15 | # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
16 | # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
17 | # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
18 | # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
19 | # spec.test_preload = 'test/assert.rb'
20 |
21 | # Values accessible as TEST_ARGS inside test scripts
22 | # spec.test_args = {'tmp_dir' => Dir::tmpdir}
23 | end
24 |
--------------------------------------------------------------------------------
/update-mruby-subtree:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REMOTE_REPO_NAME=dep-mruby
4 | REMOTE_REPO_URL=https://github.com/mruby/mruby.git
5 | SUBTREE_DIR=mruby
6 | REF=master
7 |
8 | git remote | grep ${REMOTE_REPO_NAME} > /dev/null
9 | if [ $? -ne 0 ]; then
10 | echo "Missing remote repository ${REMOTE_REPO_NAME}"
11 | echo -n "Do you want to add (y/n)? "
12 | read answer
13 | if [ X$answer = "Xy" -o X$answer = "XY" ]; then
14 | git remote add ${REMOTE_REPO_NAME} ${REMOTE_REPO_URL}
15 | echo "Added ${REMOTE_REPO_URL} as ${REMOTE_REPO_NAME}."
16 | else
17 | echo "Aborted."
18 | exit 1
19 | fi
20 | fi
21 | if [ $# -eq 1 ]; then
22 | if [ $1 = "-h" -o $1 = "--help" ]; then
23 | echo "Usage: `basename $0` [ref]"
24 | echo " 'ref' can be a SHA-1 hash, tag or branch. The default ref is 'master'."
25 | exit 0
26 | else
27 | REF=$1
28 | fi
29 | fi
30 |
31 | git subtree pull --prefix=${SUBTREE_DIR} --squash ${REMOTE_REPO_NAME} ${REF}
32 |
33 | exit 0
34 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_path.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* path conversion functions */
4 |
5 | void ndk_clean_path (ngx_str_t *path, ngx_uint_t complex, size_t off);
6 | void ndk_path_to_dir_safe (ngx_str_t *path, ngx_uint_t complex, size_t off);
7 |
8 | /* path create functions */
9 |
10 | ngx_array_t * ndk_split_path_create (ngx_conf_t *cf, ngx_str_t *path);
11 | ngx_array_t * ndk_split_path_create_raw (ngx_conf_t *cf, char *path);
12 |
13 | /* conf set functions */
14 |
15 | char * ndk_conf_set_full_path_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
16 | char * ndk_conf_set_split_path_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
17 |
18 | /* conf set post functions */
19 |
20 | char * ndk_conf_set_full_path (ngx_conf_t *cf, void *data, ngx_str_t *path);
21 | char * ndk_conf_set_full_conf_path (ngx_conf_t *cf, void *data, ngx_str_t *path);
22 |
23 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 |
5 | # Add compile flags
6 | # spec.cc.flags << ''
7 |
8 | # Add cflags to all
9 | # spec.mruby.cc.flags << '-g'
10 |
11 | # Add libraries
12 | # spec.linker.libraries << 'external_lib'
13 |
14 | # Default build files
15 | # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
16 | # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
17 | # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
18 | # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
19 | # spec.test_preload = 'test/assert.rb'
20 |
21 | # Values accessible as TEST_ARGS inside test scripts
22 | # spec.test_args = {'tmp_dir' => Dir::tmpdir}
23 | end
24 |
--------------------------------------------------------------------------------
/mruby/src/readint.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | /* mrb_read_int(): read mrb_int from a string (base 10 only) */
5 | /* const char *p - string to read */
6 | /* const char *e - end of string */
7 | /* char **endp - end of parsed integer */
8 | /* mrb_int *np - variable to save the result */
9 | /* returns TRUE if read succeeded */
10 | /* if integer overflows, returns FALSE */
11 | MRB_API mrb_bool
12 | mrb_read_int(const char *p, const char *e, char **endp, mrb_int *np)
13 | {
14 | mrb_int n = 0;
15 | int ch;
16 |
17 | while ((e == NULL || p < e) && ISDIGIT(*p)) {
18 | ch = *p - '0';
19 | if (mrb_int_mul_overflow(n, 10, &n) ||
20 | mrb_int_add_overflow(n, ch, &n)) {
21 | return FALSE;
22 | }
23 | p++;
24 | }
25 | if (endp) *endp = (char*)p;
26 | *np = n;
27 | return TRUE;
28 | }
29 |
--------------------------------------------------------------------------------
/src/stream/ngx_stream_mruby_init.c:
--------------------------------------------------------------------------------
1 | /*
2 | // ngx_stream_mruby_init.c - ngx_mruby mruby init functions
3 | //
4 | // See Copyright Notice in ngx_http_mruby_module.c
5 | */
6 |
7 | #include "ngx_stream_mruby_init.h"
8 |
9 | #include "ngx_stream_mruby_core.h"
10 | #include "ngx_stream_mruby_connection.h"
11 | #include "ngx_stream_mruby_async.h"
12 |
13 | #include
14 |
15 | #define GC_ARENA_RESTORE mrb_gc_arena_restore(mrb, 0);
16 |
17 | ngx_int_t ngx_stream_mrb_class_init(mrb_state *mrb)
18 | {
19 | struct RClass *top;
20 | struct RClass *class;
21 |
22 | /* define Nginx::Stream class */
23 | top = mrb_define_class(mrb, "Nginx", mrb->object_class);
24 | class = mrb_define_class_under(mrb, top, "Stream", mrb->object_class);
25 |
26 | ngx_stream_mrb_core_class_init(mrb, class);
27 | GC_ARENA_RESTORE;
28 | ngx_stream_mrb_conn_class_init(mrb, class);
29 | GC_ARENA_RESTORE;
30 | ngx_stream_mrb_async_class_init(mrb, class);
31 | GC_ARENA_RESTORE;
32 |
33 | return NGX_OK;
34 | }
35 |
--------------------------------------------------------------------------------
/update-devkit-subtree:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REMOTE_REPO_NAME=dep-ngx_devel_kit
4 | REMOTE_REPO_URL=https://github.com/vision5/ngx_devel_kit.git
5 | SUBTREE_DIR=dependence/ngx_devel_kit
6 | REF=master
7 |
8 | git remote | grep ${REMOTE_REPO_NAME} > /dev/null
9 | if [ $? -ne 0 ]; then
10 | echo "Missing remote repository ${REMOTE_REPO_NAME}"
11 | echo -n "Do you want to add (y/n)? "
12 | read answer
13 | if [ X$answer = "Xy" -o X$answer = "XY" ]; then
14 | git remote add ${REMOTE_REPO_NAME} ${REMOTE_REPO_URL}
15 | echo "Added ${REMOTE_REPO_URL} as ${REMOTE_REPO_NAME}."
16 | else
17 | echo "Aborted."
18 | exit 1
19 | fi
20 | fi
21 | if [ $# -eq 1 ]; then
22 | if [ $1 = "-h" -o $1 = "--help" ]; then
23 | echo "Usage: `basename $0` [ref]"
24 | echo " 'ref' can be a SHA-1 hash, tag or branch. The default ref is 'master'."
25 | exit 0
26 | else
27 | REF=$1
28 | fi
29 | fi
30 |
31 | git subtree pull --prefix=${SUBTREE_DIR} --squash ${REMOTE_REPO_NAME} ${REF}
32 |
33 | exit 0
34 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_buf.c:
--------------------------------------------------------------------------------
1 |
2 | ngx_int_t
3 | ndk_copy_chain_to_str (ngx_pool_t *pool, ngx_chain_t *in, ngx_str_t *str)
4 | {
5 | ngx_chain_t *cl;
6 | size_t len;
7 | u_char *p;
8 | ngx_buf_t *b;
9 |
10 | len = 0;
11 | for (cl = in; cl; cl = cl->next)
12 | len += ngx_buf_size (cl->buf);
13 |
14 | ndk_palloc_re (p, pool, len + 1);
15 |
16 | str->data = p;
17 | str->len = len;
18 |
19 | for (cl = in; cl; cl = cl->next) {
20 |
21 | b = cl->buf;
22 |
23 | if (ngx_buf_in_memory (b)) {
24 | p = ngx_cpymem (p, b->pos, b->last - b->pos);
25 | }
26 | }
27 |
28 | *p = '\0';
29 |
30 | return NGX_OK;
31 | }
32 |
33 |
34 | char *
35 | ndk_copy_chain_to_charp (ngx_pool_t *pool, ngx_chain_t *in)
36 | {
37 | ngx_str_t str;
38 |
39 | if (ndk_copy_chain_to_str (pool, in, &str) != NGX_OK)
40 | return NULL;
41 |
42 | return (char *) str.data;
43 | }
--------------------------------------------------------------------------------
/mruby/src/allocf.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** allocf.c - default memory allocation function
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #include
8 | #include "mruby.h"
9 |
10 | /* This function serves as the default memory allocation function and accepts four arguments:
11 | *
12 | * - `mrb`: An instance of `mrb_state`. It's important to note that for the initial allocation (used to allocate the `mrb_state` itself), `mrb` is set to NULL.
13 | * - `p`: The previous pointer to the memory region. For memory allocation, this parameter is NULL.
14 | * - `size`: The new size of the memory region to be returned.
15 | * - `ud`: User data, represented as a `void*`, which is passed to the `mrb_state`.
16 | */
17 |
18 | void*
19 | mrb_default_allocf(mrb_state *mrb, void *p, size_t size, void *ud)
20 | {
21 | if (size == 0) {
22 | /* `free(NULL)` should be no-op */
23 | free(p);
24 | return NULL;
25 | }
26 | else {
27 | /* `ralloc(NULL, size)` works as `malloc(size)` */
28 | return realloc(p, size);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/mruby/test/t/gc.rb:
--------------------------------------------------------------------------------
1 | # Not ISO specified
2 |
3 | assert('GC.enable') do
4 | assert_false GC.disable
5 | assert_true GC.enable
6 | assert_false GC.enable
7 | end
8 |
9 | assert('GC.disable') do
10 | begin
11 | assert_false GC.disable
12 | assert_true GC.disable
13 | ensure
14 | GC.enable
15 | end
16 | end
17 |
18 | assert('GC.interval_ratio=') do
19 | origin = GC.interval_ratio
20 | begin
21 | assert_equal 150, (GC.interval_ratio = 150)
22 | ensure
23 | GC.interval_ratio = origin
24 | end
25 | end
26 |
27 | assert('GC.step_ratio=') do
28 | origin = GC.step_ratio
29 | begin
30 | assert_equal 150, (GC.step_ratio = 150)
31 | ensure
32 | GC.step_ratio = origin
33 | end
34 | end
35 |
36 | assert('GC.generational_mode=') do
37 | origin = GC.generational_mode
38 | begin
39 | assert_false (GC.generational_mode = false)
40 | assert_true (GC.generational_mode = true)
41 | assert_true (GC.generational_mode = true)
42 | ensure
43 | GC.generational_mode = origin
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new('ruby_extension_example') do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 |
5 | # Add compile flags
6 | # spec.cc.flags << ''
7 |
8 | # Add cflags to all
9 | # spec.mruby.cc.flags << '-g'
10 |
11 | # Add libraries
12 | # spec.linker.libraries << 'external_lib'
13 |
14 | spec.add_dependency('mruby-print', :core => 'mruby-print')
15 |
16 | # Default build files
17 | # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
18 | # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
19 | # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
20 | # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
21 | # spec.test_preload = 'test/assert.rb'
22 |
23 | # Values accessible as TEST_ARGS inside test scripts
24 | # spec.test_args = {'tmp_dir' => Dir::tmpdir}
25 | end
26 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_uri.c:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* TODO : check that this is correct */
4 |
5 | u_char *
6 | ndk_map_uri_to_path_add_suffix (ngx_http_request_t *r, ngx_str_t *path, ngx_str_t *suffix, ngx_int_t dot)
7 | {
8 | size_t root_size;
9 | u_char *p;
10 |
11 | if (suffix->len) {
12 |
13 | if (dot) {
14 |
15 | p = ngx_http_map_uri_to_path (r, path, &root_size, suffix->len + 1);
16 |
17 | if (p == NULL)
18 | return NULL;
19 |
20 | *p = '.';
21 | p++;
22 |
23 | } else {
24 |
25 | p = ngx_http_map_uri_to_path (r, path, &root_size, suffix->len);
26 |
27 | if (p == NULL)
28 | return NULL;
29 | }
30 |
31 | path->len--;
32 |
33 | p = ngx_cpymem (p, suffix->data, suffix->len);
34 | *p = '\0';
35 |
36 | return p;
37 | }
38 |
39 | p = ngx_http_map_uri_to_path (r, path, &root_size, 0);
40 |
41 | path->len--;
42 |
43 | return p;
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/mruby/.github/linters/.markdown-lint.yml:
--------------------------------------------------------------------------------
1 | # https://github.com/DavidAnson/markdownlint#rules--aliases
2 | # markdownlint -c .github/linters/.markdown-lint.yml .
3 |
4 | # MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
5 | MD001: false
6 |
7 | # MD013 line-length - Line length
8 | MD013: false
9 |
10 | # MD014 commands-show-output - Dollar signs used before commands without showing output
11 | MD014: false
12 |
13 | # MD024 no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
14 | MD024: false
15 |
16 | # MD025 single-title/single-h1 - Multiple top-level headings in the same document
17 | MD025: false
18 |
19 | # MD026 no-trailing-punctuation - Trailing punctuation in heading
20 | MD026: false
21 |
22 | # MD033/no-inline-html - Inline HTML
23 | MD033: false
24 |
25 | # MD040 fenced-code-language - Fenced code blocks should have a language specified
26 | MD040: false
27 |
28 | # MD041 first-line-heading/first-line-h1 - First line in a file should be a top-level heading
29 | MD041: false
30 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bigint/test/bigint.rb:
--------------------------------------------------------------------------------
1 | assert 'Bigint basic' do
2 | n = 1<<65
3 | assert_equal 36893488147419103232, n
4 | assert_equal 36893488147419104229, n+997
5 | assert_equal 36893488147419102235, n-997
6 | assert_equal 36782807682976845922304, n*997
7 | assert_equal 37004501652376231, n.div(997)
8 | end
9 |
10 | assert 'Bigint to_s' do
11 | n = 1197857166996989179607278372168909873645893814254642585755536286462800958278984531968
12 | assert_equal n, "11978_571669_96989179607278372168909873645893814254642585755536286462800958278984531968".to_i
13 | assert_equal(-n, "-11978_571669_96989179607278372168909873645893814254642585755536286462800958278984531968".to_i)
14 | n = 0x1197857166996989179607278372168909873645893814254642585755536286462800958278984531968
15 | assert_equal n, "1197857166996989179607278372168909873645893814254642585755536286462800958278984531968".to_i(16)
16 | end
17 |
18 | assert 'Bigint pow' do
19 | n = 18446744073709551616
20 | assert_equal n, 2 ** 64
21 | assert_equal n, 1 << 64
22 | assert_equal 2, n >> 63
23 | end
24 |
--------------------------------------------------------------------------------
/mruby/build_config/ci/gcc-clang.rb:
--------------------------------------------------------------------------------
1 | STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
2 |
3 | MRuby::Build.new('full-debug') do |conf|
4 | conf.toolchain
5 | conf.enable_debug
6 |
7 | # include all core GEMs
8 | conf.gembox 'full-core'
9 | conf.cc.defines += %w(MRB_GC_STRESS MRB_USE_DEBUG_HOOK MRB_UTF8_STRING)
10 |
11 | conf.enable_test
12 | end
13 |
14 | MRuby::Build.new do |conf|
15 | conf.toolchain
16 |
17 | # include all core GEMs
18 | conf.gembox 'full-core'
19 | conf.gem :core => 'mruby-bin-debugger'
20 | conf.compilers.each do |c|
21 | c.defines += %w(MRB_GC_FIXED_ARENA MRB_UTF8_STRING)
22 | end
23 | conf.enable_bintest
24 | conf.enable_test
25 | end
26 |
27 | MRuby::Build.new('cxx_abi') do |conf|
28 | conf.toolchain
29 |
30 | conf.gembox 'full-core'
31 | conf.cc.flags += %w(-fpermissive -std=gnu++03)
32 | conf.compilers.each do |c|
33 | c.defines += %w(MRB_GC_FIXED_ARENA MRB_UTF8_STRING)
34 | end
35 | conf.enable_test
36 |
37 | conf.enable_cxx_abi
38 |
39 | conf.build_mrbc_exec
40 | end
41 |
--------------------------------------------------------------------------------
/mruby/build_config/serenity.rb:
--------------------------------------------------------------------------------
1 | # Cross compiling configuration for SerenityOS
2 | # Graphical Unix-like operating system for x86 computers.
3 | # https://github.com/SerenityOS/serenity
4 | #
5 | # Should be built using the SerenityOS Ports system
6 | # https://github.com/SerenityOS/serenity/tree/master/Ports
7 | #
8 | # As of 2021/08/20, SERENITY_ARCH is defined in the SerenityOS Ports
9 | # build script to always be either "i686" or "x86_64"
10 |
11 | MRuby::CrossBuild.new('serenity') do |conf|
12 | conf.toolchain :gcc
13 |
14 | conf.archiver.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-ar"
15 | conf.linker.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-g++"
16 |
17 | conf.cxx.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-g++"
18 | conf.cxx.defines << (ENV['SERENITY_ARCH'].include?('64') ? 'MRB_64BIT' : 'MRB_32BIT')
19 |
20 | conf.cc.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-gcc"
21 | conf.cc.defines << (ENV['SERENITY_ARCH'].include?('64') ? 'MRB_64BIT' : 'MRB_32BIT')
22 |
23 | conf.gembox 'full-core'
24 |
25 | conf.test_runner.command = 'env'
26 | end
27 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-string-ext/test/numeric.rb:
--------------------------------------------------------------------------------
1 | assert('Integer#chr') do
2 | assert_equal("A", 65.chr)
3 | assert_equal("B", 0x42.chr)
4 | assert_equal("\xab", 171.chr)
5 | assert_raise(RangeError) { -1.chr }
6 | assert_raise(RangeError) { 256.chr }
7 |
8 | assert_equal("A", 65.chr("ASCII-8BIT"))
9 | assert_equal("B", 0x42.chr("BINARY"))
10 | assert_equal("\xab", 171.chr("ascii-8bit"))
11 | assert_raise(RangeError) { -1.chr("binary") }
12 | assert_raise(RangeError) { 256.chr("Ascii-8bit") }
13 | assert_raise(ArgumentError) { 65.chr("ASCII") }
14 | assert_raise(ArgumentError) { 65.chr("ASCII-8BIT", 2) }
15 | assert_raise(TypeError) { 65.chr(:BINARY) }
16 |
17 | if __ENCODING__ == "ASCII-8BIT"
18 | assert_raise(ArgumentError) { 65.chr("UTF-8") }
19 | else
20 | assert_equal("A", 65.chr("UTF-8"))
21 | assert_equal("B", 0x42.chr("UTF-8"))
22 | assert_equal("«", 171.chr("utf-8"))
23 | assert_equal("あ", 12354.chr("Utf-8"))
24 | assert_raise(RangeError) { -1.chr("utf-8") }
25 | assert_raise(RangeError) { 0x110000.chr.chr("UTF-8") }
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/mruby/.github/workflows/super-linter.yml:
--------------------------------------------------------------------------------
1 | # https://github.com/super-linter/super-linter
2 | name: Super-Linter
3 |
4 | on: [pull_request]
5 |
6 | permissions:
7 | contents: read
8 |
9 | jobs:
10 | build:
11 | permissions:
12 | contents: read # for actions/checkout to fetch code
13 | statuses: write # for github/super-linter/slim to mark status of each linter run
14 | name: Lint Code Base
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
18 | uses: actions/checkout@v4
19 | with:
20 | # Full git history is needed to get a proper list of changed files within `super-linter`
21 | fetch-depth: 0
22 | - name: Lint Code Base
23 | uses: super-linter/super-linter/slim@v6.0.0
24 | env:
25 | VALIDATE_BASH: true
26 | # VALIDATE_BASH_EXEC: true
27 | # VALIDATE_EDITORCONFIG: true
28 | # VALIDATE_SHELL_SHFMT: true
29 | DEFAULT_BRANCH: master
30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 | VALIDATE_ALL_CODEBASE: false
32 |
--------------------------------------------------------------------------------
/mruby/include/mruby/endian.h:
--------------------------------------------------------------------------------
1 | /**
2 | ** @file mruby/endian.h - detect endian-ness
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #ifndef MRUBY_ENDIAN_H
8 | #define MRUBY_ENDIAN_H
9 |
10 | #include
11 |
12 | MRB_BEGIN_DECL
13 |
14 | #if !defined(BYTE_ORDER) && defined(__BYTE_ORDER__)
15 | # define BYTE_ORDER __BYTE_ORDER__
16 | #endif
17 | #if !defined(BIG_ENDIAN) && defined(__ORDER_BIG_ENDIAN__)
18 | # define BIG_ENDIAN __ORDER_BIG_ENDIAN__
19 | #endif
20 | #if !defined(LITTLE_ENDIAN) && defined(__ORDER_LITTLE_ENDIAN__)
21 | # define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
22 | #endif
23 |
24 | #ifdef BYTE_ORDER
25 | # if BYTE_ORDER == BIG_ENDIAN
26 | # define littleendian 0
27 | # elif BYTE_ORDER == LITTLE_ENDIAN
28 | # define littleendian 1
29 | # endif
30 | #endif
31 | #ifndef littleendian
32 | /* can't distinguish endian in compile time */
33 | static inline int
34 | check_little_endian(void)
35 | {
36 | unsigned int n = 1;
37 | return (*(unsigned char*)&n == 1);
38 | }
39 | # define littleendian check_little_endian()
40 | #endif
41 |
42 | MRB_END_DECL
43 |
44 | #endif /* MRUBY_ENDIAN_H */
45 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_hash.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef NDK_HASH_H
3 | #define NDK_HASH_H
4 |
5 | #ifdef NDK_HASH_ALL
6 |
7 | #ifndef NDK_MD5
8 | #define NDK_MD5
9 | #endif
10 |
11 | #ifndef NDK_MURMUR2
12 | #define NDK_MURMUR2
13 | #endif
14 |
15 | #ifndef NDK_SHA1
16 | #define NDK_SHA1
17 | #endif
18 |
19 | #endif
20 |
21 | #include
22 | #include
23 | typedef void (*ndk_hash_pt) (u_char *p, char *data, size_t len);
24 |
25 |
26 | #ifdef NDK_MD5
27 | #include
28 | void ndk_md5_hash (u_char *p, char *data, size_t len);
29 | void ndk_md5_hash_upper (u_char *p, char *data, size_t len);
30 | #endif
31 |
32 | #ifdef NDK_MURMUR2
33 | #define MURMURHASH2_DIGEST_LENGTH 4
34 | void ndk_murmur2_hash (u_char *p, char *data, size_t len);
35 | void ndk_murmur2_hash_upper (u_char *p, char *data, size_t len);
36 | #endif
37 |
38 | #ifdef NDK_SHA1
39 | #include
40 | void ndk_sha1_hash (u_char *p, char *data, size_t len);
41 | void ndk_sha1_hash_upper (u_char *p, char *data, size_t len);
42 | #endif
43 |
44 | #endif /* NDK_HASH_H */
45 |
46 |
--------------------------------------------------------------------------------
/mruby/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010- mruby developers
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a
4 | copy of this software and associated documentation files (the "Software"),
5 | to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 | and/or sell copies of the Software, and to permit persons to whom the
8 | Software is furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | DEALINGS IN THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/MITL:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 ngx_mruby developers
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a
4 | copy of this software and associated documentation files (the "Software"),
5 | to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 | and/or sell copies of the Software, and to permit persons to whom the
8 | Software is furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | DEALINGS IN THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-object-ext/mrblib/object.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 | # call-seq:
3 | # obj.yield_self {|_obj|...} -> an_object
4 | # obj.then {|_obj|...} -> an_object
5 | #
6 | # Yields obj and returns the result.
7 | #
8 | # 'my string'.yield_self {|s|s.upcase} #=> "MY STRING"
9 | #
10 | def yield_self(&block)
11 | return to_enum :yield_self unless block
12 | block.call(self)
13 | end
14 | alias then yield_self
15 |
16 | ##
17 | # call-seq:
18 | # obj.tap{|x|...} -> obj
19 | #
20 | # Yields x to the block, and then returns x.
21 | # The primary purpose of this method is to "tap into" a method chain,
22 | # in order to perform operations on intermediate results within the chain.
23 | #
24 | # (1..10) .tap {|x| puts "original: #{x.inspect}"}
25 | # .to_a .tap {|x| puts "array: #{x.inspect}"}
26 | # .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"}
27 | # .map { |x| x*x } .tap {|x| puts "squares: #{x.inspect}"}
28 | #
29 | def tap
30 | yield self
31 | self
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/conf_locs:
--------------------------------------------------------------------------------
1 |
2 | HTTP_MAIN HTTP_MAIN main
3 | HTTP_SRV HTTP_SRV srv
4 | HTTP_SIF HTTP_SRV srv
5 | HTTP_LOC HTTP_LOC loc
6 | HTTP_LIF HTTP_LOC loc
7 |
8 | HTTP_MAIN_SRV HTTP_SRV srv
9 | HTTP_MAIN_SIF HTTP_SRV srv
10 | HTTP_MAIN_LOC HTTP_LOC loc
11 | HTTP_MAIN_LIF HTTP_LOC loc
12 |
13 | HTTP_SRV_LOC HTTP_LOC loc
14 | HTTP_SRV_LIF HTTP_LOC loc
15 | HTTP_SIF_LOC HTTP_LOC loc
16 | HTTP_SIF_LIF HTTP_LOC loc
17 |
18 | HTTP_MAIN_SRV_LOC HTTP_LOC loc
19 | HTTP_MAIN_SRV_LIF HTTP_LOC loc
20 | HTTP_MAIN_SIF_LOC HTTP_LOC loc
21 | HTTP_MAIN_SRV_SIF_LOC HTTP_LOC loc
22 | HTTP HTTP_LOC loc
23 | HTTP_UPS HTTP_LOC loc
24 | HTTP_ANY HTTP_LOC loc
25 | ANY HTTP_LOC loc
26 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/test/ipsocket.rb:
--------------------------------------------------------------------------------
1 | unless SocketTest.win?
2 |
3 | # Note: most of tests below will fail if UDPSocket is broken.
4 |
5 | assert('IPSocket.getaddress') do
6 | l = IPSocket.getaddress("localhost")
7 | assert_true (l == "127.0.0.1" or l == "::1")
8 | end
9 |
10 | assert('IPSocket.addr') do
11 | localhost = "127.0.0.1"
12 | s = UDPSocket.new
13 | s.bind(localhost, 0)
14 | port = Addrinfo.new(s.getsockname).ip_port
15 |
16 | a = s.addr
17 | assert_equal "AF_INET", a[0]
18 | assert_equal port, a[1]
19 | assert_equal localhost, a[2]
20 | assert_equal localhost, a[3]
21 | s.close
22 | true
23 | end
24 |
25 | assert('IPSocket.peeraddr') do
26 | localhost = "127.0.0.1"
27 | server = UDPSocket.new
28 | server.bind(localhost, 0)
29 | port = server.local_address.ip_port
30 |
31 | client = UDPSocket.new
32 | client.connect(localhost, port)
33 |
34 | a = client.peeraddr
35 | assert_equal "AF_INET", a[0]
36 | assert_equal port, a[1]
37 | assert_equal localhost, a[2]
38 | assert_equal localhost, a[3]
39 | client.close
40 | server.close
41 | true
42 | end
43 |
44 | end # win?
45 |
--------------------------------------------------------------------------------
/mruby/include/mruby/istruct.h:
--------------------------------------------------------------------------------
1 | /**
2 | ** @file mruby/istruct.h - Inline structures
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #ifndef MRUBY_ISTRUCT_H
8 | #define MRUBY_ISTRUCT_H
9 |
10 | #include "common.h"
11 | #include
12 |
13 | /**
14 | * Inline structures that fit in RVALUE
15 | *
16 | * They cannot have finalizer, and cannot have instance variables.
17 | */
18 | MRB_BEGIN_DECL
19 |
20 | #define ISTRUCT_DATA_SIZE (sizeof(void*) * 3)
21 |
22 | struct RIStruct {
23 | MRB_OBJECT_HEADER;
24 | union {
25 | intptr_t inline_alignment[3];
26 | char inline_data[ISTRUCT_DATA_SIZE];
27 | };
28 | };
29 |
30 | #define RISTRUCT(obj) ((struct RIStruct*)(mrb_ptr(obj)))
31 | #define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
32 |
33 | MRB_INLINE mrb_int mrb_istruct_size()
34 | {
35 | return ISTRUCT_DATA_SIZE;
36 | }
37 |
38 | MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
39 | {
40 | return ISTRUCT_PTR(object);
41 | }
42 |
43 | MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
44 | {
45 | memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
46 | }
47 |
48 | MRB_END_DECL
49 |
50 | #endif /* MRUBY_ISTRUCT_H */
51 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_complex_path.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | typedef struct {
4 | ngx_array_t *a;
5 | ngx_uint_t prefix;
6 | } ndk_http_complex_path_t;
7 |
8 | typedef struct {
9 | ngx_http_complex_value_t val;
10 | ngx_flag_t dynamic;
11 | } ndk_http_complex_path_elt_t;
12 |
13 | typedef struct {
14 | ngx_str_t val;
15 | ngx_flag_t dynamic;
16 | } ndk_http_complex_path_value_t;
17 |
18 | typedef struct {
19 | ndk_http_complex_path_value_t *elts;
20 | ngx_uint_t nelts;
21 | } ndk_http_complex_path_values_t;
22 |
23 |
24 | extern ndk_http_complex_path_value_t ndk_empty_http_complex_path_value;
25 |
26 |
27 | ngx_array_t * ndk_http_complex_path_create_compile (ngx_conf_t *cf, ngx_str_t *path, ngx_uint_t prefix);
28 | ngx_int_t ndk_http_complex_path_value_compile (ngx_conf_t *cf, ngx_http_complex_value_t *cv,
29 | ngx_str_t *value, ngx_uint_t prefix);
30 | char * ndk_conf_set_http_complex_path_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
31 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-mrbc/bintest/mrbc.rb:
--------------------------------------------------------------------------------
1 | require 'tempfile'
2 |
3 | assert('Compiling multiple files without new line in last line. #2361') do
4 | a, b, out = Tempfile.new('a.rb'), Tempfile.new('b.rb'), Tempfile.new('out.mrb')
5 | a.write('module A; end')
6 | a.flush
7 | b.write('module B; end')
8 | b.flush
9 | result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} #{b.path} 2>&1`
10 | assert_equal "#{cmd_bin('mrbc')}:#{a.path}:Syntax OK", result.chomp
11 | assert_equal 0, $?.exitstatus
12 | end
13 |
14 | assert('parsing function with void argument') do
15 | a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb')
16 | a.write('f ()')
17 | a.flush
18 | result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1`
19 | assert_equal "#{cmd_bin('mrbc')}:#{a.path}:Syntax OK", result.chomp
20 | assert_equal 0, $?.exitstatus
21 | end
22 |
23 | assert('embedded document with invalid terminator') do
24 | a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb')
25 | a.write("=begin\n=endx\n")
26 | a.flush
27 | result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1`
28 | assert_equal "#{a.path}:3:0: embedded document meets end of file", result.chomp
29 | assert_equal 1, $?.exitstatus
30 | end
31 |
--------------------------------------------------------------------------------
/mruby/test/t/argumenterror.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # ArgumentError ISO Test
3 |
4 | def assert_argnum_error(given, expected, &block)
5 | assert("wrong number of arguments") do
6 | message = "wrong number of arguments (given #{given}, expected #{expected})"
7 | assert_raise_with_message(ArgumentError, message, &block)
8 | end
9 | end
10 |
11 | assert('ArgumentError', '15.2.24') do
12 | e2 = nil
13 | a = []
14 | begin
15 | # this will cause an exception due to the wrong arguments
16 | a[]
17 | rescue => e1
18 | e2 = e1
19 | end
20 |
21 | assert_equal(Class, ArgumentError.class)
22 | assert_equal(ArgumentError, e2.class)
23 | end
24 |
25 | assert("'wrong number of arguments' from mrb_get_args") do
26 | assert_argnum_error(0, "1+"){__send__}
27 | assert_argnum_error(0, 1..2){Object.const_defined?}
28 | assert_argnum_error(3, 1..2){Object.const_defined?(:A, true, 2)}
29 | assert_argnum_error(2, 0..1){{}.default(1, 2)}
30 | assert_argnum_error(1, 2){Object.const_set(:B)}
31 | assert_argnum_error(3, 2){Object.const_set(:C, 1, 2)}
32 | end
33 |
34 | assert('Call to MRB_ARGS_NONE method') do
35 | assert_raise(ArgumentError) { nil.__id__ 1 }
36 | assert_raise(ArgumentError) { nil.__id__ opts: 1 }
37 | end
38 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-set/LICENSE:
--------------------------------------------------------------------------------
1 | mruby-set
2 |
3 | Copyright (c) yui-knk 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
25 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-errno/README.md:
--------------------------------------------------------------------------------
1 | # mruby-errno
2 |
3 | Errno module for mruby
4 |
5 | ## License
6 |
7 | Copyright (c) 2013 Internet Initiative Japan Inc.
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a
10 | copy of this software and associated documentation files (the "Software"),
11 | to deal in the Software without restriction, including without limitation
12 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 | and/or sell copies of the Software, and to permit persons to whom the
14 | Software is furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 | DEALINGS IN THE SOFTWARE.
26 |
--------------------------------------------------------------------------------
/mruby/test/t/iterations.rb:
--------------------------------------------------------------------------------
1 | assert('while expression', '11.5.2.3.2') do
2 | idx = 10
3 | all = []
4 | res = while idx > 0
5 | all << idx
6 | idx -= 1
7 | end
8 |
9 | assert_equal nil, res
10 | assert_equal [10,9,8,7,6,5,4,3,2,1], all
11 | end
12 |
13 | assert('until expression', '11.5.2.3.3') do
14 | idx = 10
15 | all = []
16 | res = until idx == 0
17 | all << idx
18 | idx -= 1
19 | end
20 |
21 | assert_equal nil, res
22 | assert_equal [10,9,8,7,6,5,4,3,2,1], all
23 | end
24 |
25 | assert('break expression', '11.5.2.4.3') do
26 | assert_equal :result do
27 | while true
28 | break :result
29 | end
30 | end
31 |
32 | assert_equal :result do
33 | until false
34 | break :result
35 | end
36 | end
37 | end
38 |
39 | assert('next expression', '11.5.2.4.4') do
40 | assert_equal [8,6,4,2,0] do
41 | all = []
42 | idx = 10
43 | while idx > 0
44 | idx -= 1
45 | next if (idx % 2) == 1
46 | all << idx
47 | end
48 | all
49 | end
50 |
51 | assert_equal [8,6,4,2,0] do
52 | all = []
53 | idx = 10
54 | until idx == 0
55 | idx -= 1
56 | next if (idx % 2) == 1
57 | all << idx
58 | end
59 | all
60 | end
61 | end
62 |
--------------------------------------------------------------------------------
/mruby/src/readnum.c:
--------------------------------------------------------------------------------
1 | /* this file defines obsolete functions: mrb_int_read() and mrb_float_read() */
2 | /* use mrb_read_int() and mrb_read_float() instead */
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | /* mrb_int_read(): read mrb_int from a string (base 10 only) */
9 | /* const char *p - string to read */
10 | /* const char *e - end of string */
11 | /* char **endp - end of parsed integer */
12 |
13 | /* if integer overflows, errno will be set to ERANGE */
14 | /* also endp will be set to NULL on overflow */
15 | MRB_API mrb_int
16 | mrb_int_read(const char *p, const char *e, char **endp)
17 | {
18 | mrb_int n;
19 |
20 | if (!mrb_read_int(p, e, endp, &n)) {
21 | if (endp) *endp = NULL;
22 | errno = ERANGE;
23 | return MRB_INT_MAX;
24 | }
25 | if (endp) *endp = (char*)p;
26 | return n;
27 | }
28 |
29 | #ifndef MRB_NO_FLOAT
30 | //#include
31 | //#include
32 |
33 | MRB_API double
34 | mrb_float_read(const char *str, char **endp)
35 | {
36 | double d;
37 |
38 | if (!mrb_read_float(str, endp, &d)) {
39 | errno = ERANGE;
40 | }
41 | return d;
42 | }
43 | #endif
44 |
--------------------------------------------------------------------------------
/mruby/tasks/install.rake:
--------------------------------------------------------------------------------
1 | desc "install compiled products (on host)"
2 | task :install => "install:full:host"
3 |
4 | desc "install compiled executable (on host)"
5 | task :install_bin => "install:bin:host"
6 |
7 | desc "install compiled products (all build targets)"
8 | task "install:full"
9 |
10 | desc "install compiled executable (all build targets)"
11 | task "install:bin"
12 |
13 | MRuby.each_target do |build|
14 | next if build.internal?
15 |
16 | prefix = File.join(MRuby::INSTALL_DESTDIR, build.install_prefix)
17 |
18 | task "install:full" => "install:full:#{build.name}"
19 |
20 | task "install:full:#{build.name}" => "install:bin:#{build.name}" do
21 | Dir.glob(File.join(build.build_dir.gsub(/[\[\{\*\?]/, "\\\0"), "{include,lib}/**/*")) do |path|
22 | install_D path, File.join(prefix, path.relative_path_from(build.build_dir)) if File.file? path
23 | end
24 | end
25 |
26 | task "install:bin" => "install:bin:#{build.name}"
27 |
28 | task "install:bin:#{build.name}" => "all" do
29 | Dir.glob(File.join(build.build_dir.gsub(/[\[\{\*\?]/, "\\\0"), "{bin,host-bin}/**/*")) do |path|
30 | install_D path, File.join(prefix, path.relative_path_from(build.build_dir)) if File.file? path
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/mruby/tasks/toolchains/openwrt.rake:
--------------------------------------------------------------------------------
1 | # usage of environmental variables to set the
2 | # cross compiling toolchain proper
3 | MRuby::Toolchain.new(:openwrt) do |conf|
4 | [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc|
5 | if cc == conf.cxx
6 | cc.command = ENV['TARGET_CXX']
7 | cc.flags = ENV['TARGET_CXXFLAGS']
8 | else
9 | cc.command = ENV['TARGET_CC']
10 | cc.flags = ENV['TARGET_CFLAGS']
11 | end
12 | cc.option_include_path = %q[-I"%s"]
13 | cc.option_define = '-D%s'
14 | cc.compile_options = '%{flags} -MMD -o "%{outfile}" -c "%{infile}"'
15 | cc.preprocess_options = '%{flags} -o "%{outfile}" -E -P "%{infile}"'
16 | end
17 |
18 | conf.linker do |linker|
19 | linker.command = ENV['TARGET_CC']
20 | linker.flags = ENV['TARGET_LDFLAGS']
21 | linker.libraries = %w(m)
22 | linker.library_paths = []
23 | linker.option_library = '-l%s'
24 | linker.option_library_path = '-L%s'
25 | linker.link_options = '%{flags} -o "%{outfile}" %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}'
26 | end
27 |
28 | conf.archiver do |archiver|
29 | archiver.command = ENV['TARGET_AR']
30 | archiver.archive_options = 'rs "%{outfile}" %{objs}'
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/docs/test/README.md:
--------------------------------------------------------------------------------
1 | ngx_mruby test uses mruby test.
2 | ngx_mruby test is very earlier and experimental version.
3 |
4 | Welcome pull-request!
5 | ## Add test
6 | ##### Add location config to ``test/conf/nginx.conf``
7 | ```nginx
8 | # Nginx.hello test
9 | location /mruby {
10 | mruby_content_handler build/nginx/html/unified_hello.rb cache;
11 | }
12 | ```
13 | ##### Add hook script into ``test/html/`` if you need the script for location config
14 | ```ruby
15 | # test/htdocs/unified_hello.rb
16 | if server_name == "NGINX"
17 | Server = Nginx
18 | elsif server_name == "Apache"
19 | Server = Apache
20 | end
21 |
22 | Server::rputs "Hello #{Server::module_name}/#{Server::module_version} world!"
23 | ```
24 | ##### Add test code to ``test/t/ngx_mruby.rb``
25 | ```ruby
26 | assert('ngx_mruby', 'location /mruby') do
27 | res = HttpRequest.new.get base + '/mruby'
28 | assert_equal 'Hello ngx_mruby/0.0.1 world!', res["body"]
29 | end
30 | ```
31 | ## Testing
32 | ##### build nginx into ``./build/nginx`` and test on ``./build/nginx``
33 | ```
34 | sh test.sh
35 | ```
36 |
37 | If you want to run with valgrind, set the environment variables `NGINX_RUNNER` and `NGINX_HEATTIME`.
38 |
39 | ```console
40 | $ NGINX_RUNNER=valgrind NGINX_HEATTIME=10 sh test.sh
41 | ```
42 |
--------------------------------------------------------------------------------
/mruby/test/bintest.rb:
--------------------------------------------------------------------------------
1 | $:.unshift File.dirname(File.dirname(File.expand_path(__FILE__)))
2 | require 'test/assert.rb'
3 |
4 | GEMNAME = ""
5 |
6 | def cmd_list(s)
7 | path = s == "mrbc" ? ENV['MRBCFILE'] : "#{ENV['BUILD_DIR']}/bin/#{s}"
8 | path = path.sub(/\.exe\z/, "")
9 | if /mswin(?!ce)|mingw|bccwin/ =~ RbConfig::CONFIG['host_os']
10 | path = "#{path}.exe".tr("/", "\\")
11 | end
12 |
13 | path_list = [path]
14 |
15 | emu = ENV['EMULATOR']
16 | path_list.unshift emu if emu && !emu.empty?
17 |
18 | path_list
19 | end
20 |
21 | def cmd(s)
22 | cmd_list(s).join(' ')
23 | end
24 |
25 | def cmd_bin(s)
26 | cmd_list(s).pop
27 | end
28 |
29 | def shellquote(s)
30 | case RbConfig::CONFIG['host_os']
31 | when /mswin(?!ce)|mingw|bccwin/
32 | "\"#{s}\""
33 | else
34 | "'#{s}'"
35 | end
36 | end
37 |
38 | print "bintest - Command Binary Test\n\n"
39 |
40 | ARGV.each do |gem|
41 | case gem
42 | when '-v'; $mrbtest_verbose = true
43 | end
44 |
45 | case RbConfig::CONFIG['host_os']
46 | when /mswin(?!ce)|mingw|bccwin/
47 | gem = gem.tr('\\', '/')
48 | end
49 |
50 | Dir["#{gem}/bintest/**/*.rb"].each do |file|
51 | GEMNAME.replace(File.basename(gem))
52 | load file
53 | end
54 | end
55 |
56 | exit report
57 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-proc-ext/mrblib/proc.rb:
--------------------------------------------------------------------------------
1 | class Proc
2 |
3 | def ===(*args)
4 | call(*args)
5 | end
6 |
7 | def yield(*args)
8 | call(*args)
9 | end
10 |
11 | def to_proc
12 | self
13 | end
14 |
15 | def curry(arity=self.arity)
16 | type = :proc
17 | abs = lambda {|a| a < 0 ? -a - 1 : a}
18 | arity = abs[arity]
19 | if lambda?
20 | type = :lambda
21 | self_arity = self.arity
22 | if (self_arity >= 0 && arity != self_arity) ||
23 | (self_arity < 0 && abs[self_arity] > arity)
24 | raise ArgumentError, "wrong number of arguments (given #{arity}, expected #{abs[self_arity]})"
25 | end
26 | end
27 |
28 | pproc = self
29 | make_curry = proc do |given_args=[]|
30 | __send__(type) do |*args|
31 | new_args = given_args + args
32 | if new_args.size >= arity
33 | pproc[*new_args]
34 | else
35 | make_curry[new_args]
36 | end
37 | end
38 | end
39 | make_curry.call
40 | end
41 |
42 | def <<(other)
43 | ->(*args, **opts, &block) { call(other.call(*args, **opts, &block)) }
44 | end
45 |
46 | def >>(other)
47 | ->(*args, **opts, &block) { other.call(call(*args, **opts, &block)) }
48 | end
49 |
50 | end
51 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-socket/test/socket.rb:
--------------------------------------------------------------------------------
1 | unless SocketTest.win?
2 |
3 | assert('Socket.gethostname') do
4 | assert_true(Socket.gethostname.is_a? String)
5 | end
6 |
7 | assert('Socket::getaddrinfo') do
8 | ret = Socket.getaddrinfo("localhost", 53, Socket::AF_INET, Socket::SOCK_DGRAM)
9 | assert_true ret.size >= 1
10 | a = ret[0]
11 | assert_equal "AF_INET", a[0]
12 | assert_equal 53, a[1]
13 | # documents says it's a hostname but CRuby returns an address
14 | #assert_equal "127.0.0.1", a[2]
15 | assert_equal "127.0.0.1", a[3]
16 | assert_equal Socket::AF_INET, a[4]
17 | assert_equal Socket::SOCK_DGRAM, a[5]
18 | assert_equal Socket::IPPROTO_UDP, a[6] unless SocketTest.cygwin?
19 | end
20 |
21 | assert('Socket#recvfrom') do
22 | begin
23 | sstr = "abcdefg"
24 | s = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
25 | c = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
26 | s.bind(Socket.sockaddr_in(0, "127.0.0.1"))
27 | c.send sstr, 0, s.getsockname
28 | rstr, ai = s.recvfrom sstr.size
29 |
30 | assert_equal sstr, rstr
31 | assert_equal "127.0.0.1", ai.ip_address
32 | ensure
33 | s.close rescue nil
34 | c.close rescue nil
35 | end
36 | end
37 |
38 | end # win?
39 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk_string.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #if 1
4 | /* TODO : set ndk_hex_dump for older versions of Nginx */
5 | #define ndk_hex_dump ngx_hex_dump
6 | #endif
7 |
8 | typedef struct {
9 | size_t len;
10 | u_char *data;
11 | ngx_flag_t escaped;
12 | } ndk_estr_t;
13 |
14 | int64_t ndk_atoi64 (u_char *line, size_t n);
15 |
16 | ngx_int_t ndk_strcntc (ngx_str_t *s, char c);
17 | ngx_int_t ndk_strccnt (char *s, char c);
18 | ngx_array_t * ndk_str_array_create (ngx_pool_t *pool, char **s, ngx_int_t n);
19 | u_char * ndk_catstrf (ngx_pool_t *pool, ngx_str_t *dest, const char *fmt, ...);
20 | ngx_int_t ndk_cmpstr (ngx_str_t *s1, ngx_str_t *s2);
21 | u_char * ndk_dupstr (ngx_pool_t *pool, ngx_str_t *dest, ngx_str_t *src);
22 |
23 | static ngx_inline void
24 | ndk_strtoupper (u_char *p, size_t len)
25 | {
26 | u_char *e = p + len;
27 | for ( ; p
2 | #include
3 | #include
4 |
5 | #include
6 | #include
7 |
8 | #include
9 | #include
10 | #include "proto_to_ruby.h"
11 |
12 | using namespace ruby_fuzzer;
13 | using namespace std;
14 |
15 | int FuzzRB(const uint8_t *Data, size_t size) {
16 | mrb_value v;
17 | mrb_state *mrb = mrb_open();
18 | if (!mrb)
19 | return 0;
20 |
21 | char *code = (char*)malloc(size+1);
22 | if (!code)
23 | return 0;
24 | memcpy(code, Data, size);
25 | code[size] = '\0';
26 |
27 | if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) {
28 | // With libFuzzer binary run this to generate an RB file x.rb:
29 | // PROTO_FUZZER_DUMP_PATH=x.rb ./a.out proto-input
30 | std::ofstream of(dump_path);
31 | of.write(code, size);
32 | }
33 | std::cout << "\n\n############\n" << code << "\n############\n\n";
34 | v = mrb_load_string(mrb, code);
35 | mrb_close(mrb);
36 |
37 | free(code);
38 | return 0;
39 | }
40 |
41 | DEFINE_PROTO_FUZZER(const Function &function) {
42 | protoConverter converter;
43 | auto s = converter.FunctionToString(function);
44 | (void)FuzzRB((const uint8_t*)s.data(), s.size());
45 | }
46 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-enum-chain/mrblib/chain.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # chain.rb Enumerator::Chain class
3 | # See Copyright Notice in mruby.h
4 |
5 | module Enumerable
6 | def chain(*args)
7 | Enumerator::Chain.new(self, *args)
8 | end
9 | end
10 |
11 | class Enumerator
12 | def +(other)
13 | Chain.new(self, other)
14 | end
15 |
16 | class Chain
17 | include Enumerable
18 |
19 | def initialize(*args)
20 | @enums = args.freeze
21 | @pos = -1
22 | end
23 |
24 | def each(&block)
25 | return to_enum unless block
26 |
27 | i = 0
28 | while i < @enums.size
29 | @pos = i
30 | @enums[i].each(&block)
31 | i += 1
32 | end
33 |
34 | self
35 | end
36 |
37 | def size
38 | @enums.reduce(0) do |a, e|
39 | return nil unless e.respond_to?(:size)
40 | a + e.size
41 | end
42 | end
43 |
44 | def rewind
45 | while 0 <= @pos && @pos < @enums.size
46 | e = @enums[@pos]
47 | e.rewind if e.respond_to?(:rewind)
48 | @pos -= 1
49 | end
50 |
51 | self
52 | end
53 |
54 | def +(other)
55 | self.class.new(self, other)
56 | end
57 |
58 | def inspect
59 | "#<#{self.class}: #{@enums.inspect}>"
60 | end
61 | end
62 | end
63 |
--------------------------------------------------------------------------------
/mruby/test/t/unicode.rb:
--------------------------------------------------------------------------------
1 | # Test of the \u notation
2 |
3 | assert('bare \u notation test') do
4 | # Minimum and maximum one byte characters
5 | assert_equal("\x00", "\u0000")
6 | assert_equal("\x7F", "\u007F")
7 |
8 | # Minimum and maximum two byte characters
9 | assert_equal("\xC2\x80", "\u0080")
10 | assert_equal("\xDF\xBF", "\u07FF")
11 |
12 | # Minimum and maximum three byte characters
13 | assert_equal("\xE0\xA0\x80", "\u0800")
14 | assert_equal("\xEF\xBF\xBF", "\uFFFF")
15 |
16 | # Four byte characters require the \U notation
17 | end
18 |
19 | assert('braced \u notation test') do
20 | # Minimum and maximum one byte characters
21 | assert_equal("\x00", "\u{0000}")
22 | assert_equal("\x7F", "\u{007F}")
23 |
24 | # Minimum and maximum two byte characters
25 | assert_equal("\xC2\x80", "\u{0080}")
26 | assert_equal("\xDF\xBF", "\u{07FF}")
27 |
28 | # Minimum and maximum three byte characters
29 | assert_equal("\xE0\xA0\x80", "\u{0800}")
30 | assert_equal("\xEF\xBF\xBF", "\u{FFFF}")
31 |
32 | # Minimum and maximum four byte characters
33 | assert_equal("\xF0\x90\x80\x80", "\u{10000}")
34 | assert_equal("\xF4\x8F\xBF\xBF", "\u{10FFFF}")
35 | end
36 |
37 | assert('braced multiple \u notation test') do
38 | assert_equal("ABC", "\u{41 42 43}")
39 | end
40 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/src/ndk.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * 2010 (C) Marcus Clyne
4 | */
5 |
6 |
7 | #ifndef NDK_H
8 | #define NDK_H
9 |
10 |
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | #define ndk_version 2015
17 | #define NDK_VERSION "0.2.15"
18 |
19 |
20 | #if (NGX_DEBUG)
21 | #ifndef NDK_DEBUG
22 | #define NDK_DEBUG 1
23 | #endif
24 | #else
25 | #ifndef NDK_DEBUG
26 | #define NDK_DEBUG 0
27 | #endif
28 | #endif
29 |
30 |
31 | #if !(NDK)
32 | #error At least one module requires the Nginx Development Kit to be compiled with \
33 | the source (add --with-module=/path/to/devel/kit/src to configure command)
34 | #endif
35 |
36 | #include
37 |
38 |
39 | #if (NDK_HTTP_CREATE_MAIN_CONF)
40 |
41 | #define ndk_http_conf_get_main_conf(cf) ngx_http_conf_get_module_main_conf (cf, ndk_http_module)
42 | #define ndk_http_get_main_conf(r) ngx_http_get_module_main_conf (r, ndk_http_module)
43 |
44 | typedef struct {
45 | #if (NDK_UPSTREAM_LIST)
46 | ngx_array_t *upstreams;
47 | #endif
48 | } ndk_http_main_conf_t;
49 |
50 | #endif /* NDK_HTTP_CREATE_MAIN_CONF */
51 |
52 | #include
53 |
54 |
55 | extern ngx_module_t ndk_http_module;
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/mruby/include/mruby/presym/enable.h:
--------------------------------------------------------------------------------
1 | /**
2 | ** @file mruby/presym/enable.h - Enable Preallocated Symbols
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #ifndef MRUBY_PRESYM_ENABLE_H
8 | #define MRUBY_PRESYM_ENABLE_H
9 |
10 | #include
11 |
12 | #define MRB_OPSYM(name) MRB_OPSYM__##name
13 | #define MRB_CVSYM(name) MRB_CVSYM__##name
14 | #define MRB_IVSYM(name) MRB_IVSYM__##name
15 | #define MRB_SYM_B(name) MRB_SYM_B__##name
16 | #define MRB_SYM_Q(name) MRB_SYM_Q__##name
17 | #define MRB_SYM_E(name) MRB_SYM_E__##name
18 | #define MRB_SYM(name) MRB_SYM__##name
19 |
20 | #define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name
21 | #define MRB_CVSYM_2(mrb, name) MRB_CVSYM__##name
22 | #define MRB_IVSYM_2(mrb, name) MRB_IVSYM__##name
23 | #define MRB_SYM_B_2(mrb, name) MRB_SYM_B__##name
24 | #define MRB_SYM_Q_2(mrb, name) MRB_SYM_Q__##name
25 | #define MRB_SYM_E_2(mrb, name) MRB_SYM_E__##name
26 | #define MRB_SYM_2(mrb, name) MRB_SYM__##name
27 |
28 | #define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
29 | static const mrb_sym name[] = {__VA_ARGS__};
30 |
31 | #define MRB_PRESYM_INIT_SYMBOLS(mrb, name) (void)(mrb)
32 |
33 | /* use MRB_SYM() for E_RUNTIME_ERROR etc. */
34 | #undef MRB_ERROR_SYM
35 | #define MRB_ERROR_SYM(sym) MRB_SYM(sym)
36 |
37 | #endif /* MRUBY_PRESYM_ENABLE_H */
38 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** apibreak.h
3 | **
4 | */
5 |
6 | #ifndef APIBREAK_H_
7 | #define APIBREAK_H_
8 |
9 | #include
10 | #include "mrdb.h"
11 |
12 | int32_t mrb_debug_set_break_line(mrb_state*, mrb_debug_context*, const char*, uint16_t);
13 | int32_t mrb_debug_set_break_method(mrb_state*, mrb_debug_context*, const char*, const char*);
14 | int32_t mrb_debug_get_breaknum(mrb_state*, mrb_debug_context*);
15 | int32_t mrb_debug_get_break_all(mrb_state*, mrb_debug_context*, uint32_t, mrb_debug_breakpoint bp[]);
16 | int32_t mrb_debug_get_break(mrb_state*, mrb_debug_context*, uint32_t, mrb_debug_breakpoint*);
17 | int32_t mrb_debug_delete_break(mrb_state*, mrb_debug_context*, uint32_t);
18 | int32_t mrb_debug_delete_break_all(mrb_state*, mrb_debug_context*);
19 | int32_t mrb_debug_enable_break(mrb_state*, mrb_debug_context*, uint32_t);
20 | int32_t mrb_debug_enable_break_all(mrb_state*, mrb_debug_context*);
21 | int32_t mrb_debug_disable_break(mrb_state*, mrb_debug_context*, uint32_t);
22 | int32_t mrb_debug_disable_break_all(mrb_state*, mrb_debug_context*);
23 | int32_t mrb_debug_check_breakpoint_line(mrb_state*, mrb_debug_context*, const char*, uint16_t);
24 | int32_t mrb_debug_check_breakpoint_method(mrb_state*, mrb_debug_context*, struct RClass*, mrb_sym, mrb_bool*);
25 |
26 | #endif /* APIBREAK_H_ */
27 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-method/README.md:
--------------------------------------------------------------------------------
1 | # mruby-method
2 |
3 | An implementation of class **Method** and **UnboundMethod** for mruby
4 |
5 | ```ruby
6 | p Enumerable.instance_method(:find_all).source_location
7 | #=> ["mruby/mruby/mrblib/enum.rb", 148]
8 | ```
9 |
10 | # Note
11 |
12 | You need to enable debug option in your build configuration to use
13 | `source_location` method in this gem, for example:
14 |
15 | ```ruby
16 | MRuby::Build.new do |conf|
17 | conf.enable_debug
18 | end
19 | ```
20 |
21 | # Supported Methods
22 |
23 | ## Kernel
24 |
25 | - `Kernel#method`
26 | - `Kernel#singleton_method`
27 |
28 | ## Module
29 |
30 | - `Module#instance_method`
31 |
32 | ## Method class
33 |
34 | - `Method#name`
35 | - `Method#call`
36 | - `Method#super_method`
37 | - `Method#arity`
38 | - `Method#unbind`
39 | - `Method#[]`
40 | - `Method#owner`
41 | - `Method#receiver`
42 | - `Method#parameters`
43 | - `Method#source_location`
44 | - `Method#to_proc`
45 |
46 | ## UnboundMethod class
47 |
48 | - `UnboundMethod#name`
49 | - `UnboundMethod#bind`
50 | - `UnboundMethod#super_method`
51 | - `UnboundMethod#arity`
52 | - `UnboundMethod#owner`
53 | - `UnboundMethod#parameters`
54 | - `UnboundMethod#source_location`
55 |
56 | # See also
57 |
58 | -
59 | -
60 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-compiler/mrbgem.rake:
--------------------------------------------------------------------------------
1 | MRuby::Gem::Specification.new 'mruby-compiler' do |spec|
2 | spec.license = 'MIT'
3 | spec.author = 'mruby developers'
4 | spec.summary = 'mruby compiler library'
5 |
6 | objs = %w[codegen y.tab].map do |name|
7 | src = "#{dir}/core/#{name}.c"
8 | if build.cxx_exception_enabled?
9 | build.compile_as_cxx(src)
10 | else
11 | objfile(src.pathmap("#{build_dir}/core/%n"))
12 | end
13 | end
14 | build.libmruby_core_objs << objs
15 | end
16 |
17 | if MRuby::Build.current.name == "host"
18 | dir = __dir__
19 | lex_def = "#{dir}/core/lex.def"
20 |
21 | # Parser
22 | file "#{dir}/core/y.tab.c" => ["#{dir}/core/parse.y", lex_def] do |t|
23 | MRuby.targets["host"].yacc.run t.name, t.prerequisites.first
24 | replace_line_directive(t.name)
25 | end
26 |
27 | # Lexical analyzer
28 | file lex_def => "#{dir}/core/keywords" do |t|
29 | MRuby.targets["host"].gperf.run t.name, t.prerequisites.first
30 | replace_line_directive(t.name)
31 | end
32 |
33 | def replace_line_directive(path)
34 | content = File.read(path).gsub(%r{
35 | ^\#line\s+\d+\s+"\K.*(?="$) | # #line directive
36 | ^/\*\s+Command-line:.*\s\K\S+(?=\s+\*/$) # header comment in lex.def
37 | }x, &:relative_path)
38 | File.write(path, content)
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/docs/upstream/list:
--------------------------------------------------------------------------------
1 |
2 | NDK_UPSTREAM_LIST
3 | -----------------
4 |
5 | This submodule provides a directive that creates a list of upstreams, with
6 | optional weighting. This list can then be used by other modules to hash over
7 | the upstreams however they choose.
8 |
9 |
10 | USAGE IN CONF FILE
11 | ------------------
12 |
13 | e.g. upstream_list name backend1 4:backend2 3:backend3;
14 |
15 |
16 |
17 | USAGE WITH OTHER MODULES
18 | ------------------------
19 |
20 | Add a line like
21 |
22 | CFLAGS="$CFLAGS -DNDK_UPSTREAM_LIST"
23 |
24 | to the config file of your module.
25 |
26 |
27 |
28 | INTEGRATING WITH YOUR MODULE
29 | ----------------------------
30 |
31 | The upstream lists are stored in the array given in the lists.h file, which is
32 | an array of ndk_upstream_list_t elts. The elts are currently all pointers to
33 | strings which have been distributed according to the weight - so if there are
34 | two backends, with weight 3 and 4 respectively, there will be 7 pointers in
35 | total with the first 3 pointing to the first backend and the last 4 to the
36 | second.
37 |
38 |
39 |
40 | TODO
41 | ----
42 | - replace strings with pointers to upstreams if they are available (and if
43 | this is possible)
44 | - add additional 'http://' to strings if necessary
45 | - improve this documentation
46 |
--------------------------------------------------------------------------------
/mruby/tasks/mrblib.rake:
--------------------------------------------------------------------------------
1 | MRuby.each_target do
2 | next unless libmruby_enabled?
3 |
4 | src = "#{build_dir}/mrblib/mrblib.c"
5 | rbfiles = Dir["#{MRUBY_ROOT}/mrblib/*.rb"].sort!
6 |
7 | self.libmruby_objs << objfile(src.ext)
8 |
9 | file src => [mrbcfile, __FILE__, *rbfiles] do |t|
10 | if presym_enabled?
11 | cdump = true
12 | suffix = "proc"
13 | else
14 | cdump = false
15 | suffix = "irep"
16 | end
17 | mkdir_p File.dirname(t.name)
18 | File.open(t.name, 'w') do |f|
19 | _pp "GEN", "mrblib/*.rb", "#{t.name.relative_path}"
20 | f.puts %Q[/*]
21 | f.puts %Q[ * This file is loading the mrblib]
22 | f.puts %Q[ *]
23 | f.puts %Q[ * IMPORTANT:]
24 | f.puts %Q[ * This file was generated!]
25 | f.puts %Q[ * All manual changes will get lost.]
26 | f.puts %Q[ */]
27 | unless presym_enabled?
28 | f.puts %Q[#include ]
29 | f.puts %Q[#include ]
30 | end
31 | mrbc.run f, rbfiles, "mrblib_#{suffix}", cdump: cdump, static: true
32 | f.puts %Q[void]
33 | f.puts %Q[mrb_init_mrblib(mrb_state *mrb)]
34 | f.puts %Q[{]
35 | f.puts %Q[ mrblib_#{suffix}_init_syms(mrb);] if cdump
36 | f.puts %Q[ mrb_load_#{suffix}(mrb, mrblib_#{suffix});]
37 | f.puts %Q[}]
38 | end
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/mruby/include/mruby/object.h:
--------------------------------------------------------------------------------
1 | /**
2 | ** @file mruby/object.h - mruby object definition
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #ifndef MRUBY_OBJECT_H
8 | #define MRUBY_OBJECT_H
9 |
10 | #define MRB_OBJECT_HEADER \
11 | struct RClass *c; \
12 | struct RBasic *gcnext; \
13 | enum mrb_vtype tt:8; \
14 | uint32_t color:3; \
15 | uint32_t flags:21
16 |
17 | #define MRB_FLAG_TEST(obj, flag) ((obj)->flags & (flag))
18 |
19 | struct RBasic {
20 | MRB_OBJECT_HEADER;
21 | };
22 | #define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
23 |
24 | #define MRB_FL_OBJ_IS_FROZEN (1 << 20)
25 | #define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
26 | #define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
27 | #define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
28 | #define mrb_frozen_p(o) MRB_FROZEN_P(o)
29 |
30 | struct RObject {
31 | MRB_OBJECT_HEADER;
32 | struct iv_tbl *iv;
33 | };
34 | #define mrb_obj_ptr(v) ((struct RObject*)(mrb_ptr(v)))
35 |
36 | #define mrb_special_const_p(x) mrb_immediate_p(x)
37 |
38 | struct RFiber {
39 | MRB_OBJECT_HEADER;
40 | struct mrb_context *cxt;
41 | };
42 |
43 | #define mrb_static_assert_object_size(st) \
44 | mrb_static_assert(sizeof(st) <= sizeof(void*) * 6, \
45 | #st " size must be within 6 words")
46 |
47 | #endif /* MRUBY_OBJECT_H */
48 |
--------------------------------------------------------------------------------
/mruby/benchmark/bm_so_lists.rb:
--------------------------------------------------------------------------------
1 | # from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
2 | # which is lost long time ago. The past content can be retrieved from
3 | # https://web.archive.org/web/20040805115204/http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
4 |
5 | NUM = 300
6 | SIZE = 10000
7 |
8 | def test_lists
9 | # create a list of integers (Li1) from 1 to SIZE
10 | li1 = (1..SIZE).to_a
11 | # copy the list to li2 (not by individual items)
12 | li2 = li1.dup
13 | # remove each individual item from left side of li2 and
14 | # append to right side of li3 (preserving order)
15 | li3 = Array.new
16 | while (not li2.empty?)
17 | li3.push(li2.shift)
18 | end
19 | # li2 must now be empty
20 | # remove each individual item from right side of li3 and
21 | # append to right side of li2 (reversing list)
22 | until li3.empty?
23 | li2.push(li3.pop)
24 | end
25 | # li3 must now be empty
26 | # reverse li1 in place
27 | li1.reverse!
28 | # check that first item is now SIZE
29 | if li1[0] != SIZE
30 | p "not SIZE"
31 | 0
32 | else
33 | # compare li1 and li2 for equality
34 | if li1 != li2
35 | return(0)
36 | else
37 | # return the length of the list
38 | li1.length
39 | end
40 | end
41 | end
42 |
43 | i = 0
44 | while ioffset);
15 | if (ep->from && ep->to)
16 | return "is duplicate";
17 |
18 | value = cf->args->elts;
19 |
20 |
21 | if (ep->from) {
22 |
23 | ep->to = (char *) value[1].data;
24 | len = strlen (ep->from);
25 |
26 | } else if (ep->to) {
27 |
28 | ep->from = (char *) value[1].data;
29 | len = strlen (ep->to);
30 |
31 | } else {
32 | return "has no base encoding";
33 | }
34 |
35 |
36 | if (len == value[1].len && !strncasecmp (ep->to, ep->from, len)) {
37 |
38 | ngx_log_error (NGX_LOG_WARN, cf->log, 0,
39 | "\"%V\" '%V' encoding is ignored (no conversion)", &value[0], &value[1]);
40 |
41 | return NGX_CONF_OK;
42 | }
43 |
44 |
45 | ic = iconv_open (ep->to, ep->from);
46 | if (ic == (iconv_t)-1)
47 | return "has an invalid encoding";
48 |
49 |
50 | if (iconv_close (ic)) {
51 | ngx_log_error (NGX_LOG_EMERG, cf->log, errno, "iconv_close()");
52 | return NGX_CONF_ERROR;
53 | }
54 |
55 | return NGX_CONF_OK;
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-object-ext/test/object.rb:
--------------------------------------------------------------------------------
1 | assert('Object#instance_exec') do
2 | class KlassWithSecret
3 | def initialize
4 | @secret = 99
5 | end
6 | end
7 | k = KlassWithSecret.new
8 | assert_equal 104, k.instance_exec(5) {|x| @secret+x }
9 | end
10 |
11 | assert('Object#tap') do
12 | ret = []
13 | (1..10) .tap {|x| ret << "original: #{x.inspect}"}
14 | .to_a .tap {|x| ret << "array: #{x.inspect}"}
15 | .select {|x| x%2==0} .tap {|x| ret << "evens: #{x.inspect}"}
16 | .map { |x| x*x } .tap {|x| ret << "squares: #{x.inspect}"}
17 |
18 | assert_equal [
19 | "original: 1..10",
20 | "array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
21 | "evens: [2, 4, 6, 8, 10]",
22 | "squares: [4, 16, 36, 64, 100]"
23 | ], ret
24 | assert_equal(:tap_ok, Class.new {def m; tap{return :tap_ok}; end}.new.m)
25 | end
26 |
27 | assert('instance_exec on primitives with class and module definition') do
28 | begin
29 | class A
30 | 1.instance_exec do
31 | class B
32 | end
33 | end
34 | end
35 |
36 | assert_kind_of Class, A::B
37 | ensure
38 | Object.remove_const :A
39 | end
40 |
41 | begin
42 | class A
43 | 1.instance_exec do
44 | module B
45 | end
46 | end
47 | end
48 |
49 | assert_kind_of Module, A::B
50 | ensure
51 | Object.remove_const :A
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/objs/ndk_includes.h:
--------------------------------------------------------------------------------
1 | /* optional includes */
2 |
3 | #if (NDK_BUF)
4 | #include
5 | #endif
6 | #if (NDK_COMPLEX_PATH)
7 | #include
8 | #endif
9 | #if (NDK_COMPLEX_VALUE)
10 | #include
11 | #endif
12 | #if (NDK_CONF_FILE)
13 | #include
14 | #endif
15 | #if (NDK_ENCODING)
16 | #include
17 | #endif
18 | #if (NDK_HASH)
19 | #include
20 | #endif
21 | #if (NDK_HTTP)
22 | #include
23 | #endif
24 | #if (NDK_PATH)
25 | #include
26 | #endif
27 | #if (NDK_PROCESS)
28 | #include
29 | #endif
30 | #if (NDK_REGEX)
31 | #include
32 | #endif
33 | #if (NDK_REWRITE)
34 | #include
35 | #endif
36 | #if (NDK_SET_VAR)
37 | #include
38 | #endif
39 | #if (NDK_STRING)
40 | #include
41 | #endif
42 | #if (NDK_UPSTREAM_LIST)
43 | #include
44 | #endif
45 | #if (NDK_URI)
46 | #include
47 | #endif
48 |
49 |
50 | /* non-optional includes */
51 |
52 | #include
53 | #include
54 | #include
55 | #include
56 |
57 |
58 | /* auto-generated headers */
59 |
60 | #include
61 | #include
62 | #include
63 | #include
64 | #include
65 |
66 |
67 |
--------------------------------------------------------------------------------
/mruby/src/init.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** init.c - initialize mruby core
3 | **
4 | ** See Copyright Notice in mruby.h
5 | */
6 |
7 | #include
8 |
9 | void mrb_init_symtbl(mrb_state*);
10 | void mrb_init_class(mrb_state*);
11 | void mrb_init_object(mrb_state*);
12 | void mrb_init_kernel(mrb_state*);
13 | void mrb_init_enumerable(mrb_state*);
14 | void mrb_init_symbol(mrb_state*);
15 | void mrb_init_string(mrb_state*);
16 | void mrb_init_exception(mrb_state*);
17 | void mrb_init_proc(mrb_state*);
18 | void mrb_init_array(mrb_state*);
19 | void mrb_init_hash(mrb_state*);
20 | void mrb_init_numeric(mrb_state*);
21 | void mrb_init_range(mrb_state*);
22 | void mrb_init_gc(mrb_state*);
23 | void mrb_init_math(mrb_state*);
24 | void mrb_init_version(mrb_state*);
25 | void mrb_init_mrblib(mrb_state*);
26 |
27 | #define DONE mrb_gc_arena_restore(mrb, 0);
28 | void
29 | mrb_init_core(mrb_state *mrb)
30 | {
31 | mrb_init_symtbl(mrb); DONE;
32 |
33 | mrb_init_class(mrb); DONE;
34 | mrb_init_object(mrb); DONE;
35 | mrb_init_kernel(mrb); DONE;
36 | mrb_init_enumerable(mrb); DONE;
37 |
38 | mrb_init_symbol(mrb); DONE;
39 | mrb_init_string(mrb); DONE;
40 | mrb_init_exception(mrb); DONE;
41 | mrb_init_proc(mrb); DONE;
42 | mrb_init_array(mrb); DONE;
43 | mrb_init_hash(mrb); DONE;
44 | mrb_init_numeric(mrb); DONE;
45 | mrb_init_range(mrb); DONE;
46 | mrb_init_gc(mrb); DONE;
47 | mrb_init_version(mrb); DONE;
48 | mrb_init_mrblib(mrb); DONE;
49 | }
50 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-enum-lazy/test/lazy.rb:
--------------------------------------------------------------------------------
1 | assert("Enumerator::Lazy") do
2 | a = [1, 2]
3 | assert_equal Enumerator::Lazy, a.lazy.class
4 | end
5 |
6 | assert("Enumerator::Lazy laziness") do
7 | a = Object.new
8 | def a.each
9 | return to_enum :each unless block_given?
10 | self.b << 10
11 | yield 1
12 | self.b << 20
13 | yield 2
14 | self.b << 30
15 | yield 3
16 | self.b << 40
17 | yield 4
18 | self.b << 50
19 | yield 5
20 | end
21 | def a.b(b=nil)
22 | @b = b if b
23 | @b
24 | end
25 |
26 | a.b([])
27 | assert_equal [1,2], a.each.lazy.take(2).force
28 | assert_equal [10,20], a.b
29 |
30 | a.b([])
31 | assert_equal [2,4], a.each.lazy.select{|x|x%2==0}.take(2).force
32 | assert_equal [10,20,30,40], a.b
33 |
34 | a.b([])
35 | assert_equal [1], a.each.lazy.take_while{|x|x<2}.take(1).force
36 | assert_equal [10], a.b
37 |
38 | a.b([])
39 | assert_equal [1], a.each.lazy.take_while{|x|x<2}.take(4).force
40 | assert_equal [10,20], a.b
41 | end
42 |
43 | assert("Enumerator::Lazy#to_enum") do
44 | lazy_enum = (0..).lazy.to_enum(:each_slice, 2)
45 | assert_kind_of Enumerator::Lazy, lazy_enum
46 | assert_equal [0*1, 2*3, 4*5, 6*7], lazy_enum.map { |a| a.first * a.last }.first(4)
47 | end
48 |
49 | assert("Enumerator::Lazy#zip with cycle") do
50 | e1 = [1, 2, 3].cycle
51 | e2 = [:a, :b].cycle
52 | assert_equal [[1,:a],[2,:b],[3,:a]], e1.lazy.zip(e2).first(3)
53 | end
54 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-proc-binding/src/proc-binding.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | /* provided by mruby-proc-ext */
7 | mrb_value mrb_proc_source_location(mrb_state *mrb, const struct RProc *p);
8 |
9 | /* provided by mruby-binding */
10 | mrb_value mrb_binding_new(mrb_state *mrb, const struct RProc *proc, mrb_value recv, struct REnv *env);
11 |
12 | static mrb_value
13 | mrb_proc_binding(mrb_state *mrb, mrb_value procval)
14 | {
15 | const struct RProc *proc = mrb_proc_ptr(procval);
16 | struct REnv *env;
17 |
18 | mrb_value receiver;
19 | if (!proc || MRB_PROC_CFUNC_P(proc) || !proc->upper || MRB_PROC_CFUNC_P(proc->upper)) {
20 | env = NULL;
21 | proc = NULL;
22 | receiver = mrb_nil_value();
23 | }
24 | else {
25 | env = MRB_PROC_ENV(proc);
26 | mrb_assert(env);
27 | proc = proc->upper;
28 | receiver = MRB_ENV_LEN(env) > 0 ? env->stack[0] : mrb_nil_value();
29 | }
30 |
31 | mrb_value binding = mrb_binding_new(mrb, proc, receiver, env);
32 | mrb_iv_set(mrb, binding, MRB_SYM(source_location), mrb_proc_source_location(mrb, mrb_proc_ptr(procval)));
33 | return binding;
34 | }
35 |
36 | void
37 | mrb_mruby_proc_binding_gem_init(mrb_state *mrb)
38 | {
39 | mrb_define_method(mrb, mrb->proc_class, "binding", mrb_proc_binding, MRB_ARGS_NONE());
40 | }
41 |
42 | void
43 | mrb_mruby_proc_binding_gem_final(mrb_state *mrb)
44 | {
45 | }
46 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/auto/data/conf_macros:
--------------------------------------------------------------------------------
1 |
2 | BITMASK 1MORE bitmask
3 | BUFS TAKE1 bufs
4 | COMPLEX_KEYVAL TAKE2 http_complex_keyval
5 | COMPLEX_PATH TAKE1 http_complex_path
6 | COMPLEX_VALUE TAKE1 http_complex_value
7 | COMPLEX_VALUE_ARRAY 1MORE http_complex_value_array
8 | ENCODING TAKE1 encoding
9 | ENUM TAKE1 enum
10 | FALSE NOARGS false
11 | FULL_PATH TAKE1 full_path
12 | KEYVAL TAKE2 keyval
13 | KEYVAL1 TAKE2 keyval1
14 | MSEC TAKE1 msec
15 | NULL NOARGS null
16 | NUM TAKE1 num
17 | NUM64 TAKE1 num64
18 | NUM_FLAG TAKE1 num_flag
19 | ONOFF FLAG flag
20 | OFF TAKE1 off
21 | PATH TAKE1 split_path
22 | REXEX TAKE1 regex
23 | REGEX_CL TAKE1 regex_caseless
24 | REGEX_ARRAY 1MORE regex_array
25 | REGEX_ARRAY_CL 1MORE regex_array_caseless
26 | PTR NOARGS ptr
27 | SEC TAKE1 sec
28 | SEC_FLAG TAKE2 sec_flag
29 | SIZE TAKE1 size
30 | STR TAKE1 str
31 | STR_ARRAY 1MORE str_array_multi
32 | STR_ARRAY1 TAKE1 str_array
33 | TRUE NOARGS true
34 |
35 |
36 |
--------------------------------------------------------------------------------
/mruby/mrbgems/mruby-cmath/test/cmath.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # CMath Test
3 |
4 | def assert_complex(c1, c2)
5 | assert('assert_complex') do
6 | assert_float(c1.real, c2.real)
7 | assert_float(c1.imaginary, c2.imaginary)
8 | end
9 | end
10 |
11 | assert('CMath.exp') do
12 | assert_float(1.0, CMath.exp(0))
13 | assert_complex(-1+0i, CMath.exp(Math::PI.i))
14 | assert_complex((-1.1312043837568135+2.4717266720048188i), CMath.exp(1+2i))
15 | end
16 |
17 | assert('CMath.log') do
18 | assert_float(0, CMath.log(1))
19 | assert_float(3.0, CMath.log(8,2))
20 | assert_complex((1.092840647090816-0.42078724841586035i), CMath.log(-8,-2))
21 | end
22 |
23 | assert('CMath.sqrt') do
24 | assert_complex(Complex(0,2), CMath.sqrt(-4.0))
25 | assert_complex(Complex(0,3), CMath.sqrt(-9.0))
26 | end
27 |
28 | assert('CMath trigonometric_functions') do
29 | assert_complex(Math.sinh(2).i, CMath.sin(2i))
30 | assert_complex(Math.cosh(2)+0i, CMath.cos(2i))
31 | assert_complex(Math.tanh(2).i, CMath.tan(2i))
32 | assert_complex(Math.sin(2).i, CMath.sinh(2i))
33 | assert_complex(Math.cos(2)+0i, CMath.cosh(2i))
34 | assert_complex(Math.tan(2).i, CMath.tanh(2i))
35 | assert_complex(1+1i, CMath.sin(CMath.asin(1+1i)))
36 | assert_complex(1+1i, CMath.cos(CMath.acos(1+1i)))
37 | assert_complex(1+1i, CMath.tan(CMath.atan(1+1i)))
38 | assert_complex(1+1i, CMath.sinh(CMath.asinh(1+1i)))
39 | assert_complex(1+1i, CMath.cosh(CMath.acosh(1+1i)))
40 | assert_complex(1+1i, CMath.tanh(CMath.atanh(1+1i)))
41 | end
42 |
--------------------------------------------------------------------------------
/mruby/mrblib/10error.rb:
--------------------------------------------------------------------------------
1 | class Exception
2 | ##
3 | # call-seq:
4 | # exception.message -> string
5 | #
6 | # Returns the result of invoking exception.to_s.
7 | # Normally this returns the exception's message or name.
8 | #
9 | def message
10 | to_s
11 | end
12 | end
13 |
14 | # ISO 15.2.24
15 | class ArgumentError < StandardError
16 | end
17 |
18 | # ISO 15.2.25
19 | class LocalJumpError < StandardError
20 | end
21 |
22 | # ISO 15.2.26
23 | class RangeError < StandardError
24 | end
25 |
26 | class FloatDomainError < RangeError
27 | end
28 |
29 | # ISO 15.2.26
30 | class RegexpError < StandardError
31 | end
32 |
33 | # ISO 15.2.29
34 | class TypeError < StandardError
35 | end
36 |
37 | # ISO 15.2.30
38 | class ZeroDivisionError < StandardError
39 | end
40 |
41 | # ISO 15.2.31
42 | class NameError < StandardError
43 | attr_accessor :name
44 |
45 | def initialize(message=nil, name=nil)
46 | @name = name
47 | super(message)
48 | end
49 | end
50 |
51 | # ISO 15.2.32
52 | class NoMethodError < NameError
53 | attr_reader :args
54 |
55 | def initialize(message=nil, name=nil, args=nil)
56 | @args = args
57 | super message, name
58 | end
59 | end
60 |
61 | # ISO 15.2.33
62 | class IndexError < StandardError
63 | end
64 |
65 | class KeyError < IndexError
66 | end
67 |
68 | class NotImplementedError < ScriptError
69 | end
70 |
71 | class FrozenError < RuntimeError
72 | end
73 |
74 | class StopIteration < IndexError
75 | attr_accessor :result
76 | end
77 |
--------------------------------------------------------------------------------
/dependence/ngx_devel_kit/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010-2018, Marcus Clyne
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 |
--------------------------------------------------------------------------------